C++學生成績統(tǒng)計管理系統(tǒng)_第1頁
C++學生成績統(tǒng)計管理系統(tǒng)_第2頁
C++學生成績統(tǒng)計管理系統(tǒng)_第3頁
C++學生成績統(tǒng)計管理系統(tǒng)_第4頁
C++學生成績統(tǒng)計管理系統(tǒng)_第5頁
已閱讀5頁,還剩25頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領

文檔簡介

1、信計0901班譚鄱侖湖南科技學院課程設計報告課程名稱:計算機高級語言(C+)課程設計課程設計題目:學生通訊管理系統(tǒng)系:數(shù)學與計算科學系專 業(yè):信息與計算科學年級、班:信計0801姓 名:譚鄱侖學 號:200905002109指導教師:牛志毅職 稱:講師2010年12月目 錄課程實驗報告-3一、需求分析-3二、概要設計-3 三、程序?qū)崿F(xiàn)思路-7四、設計總結(jié)-7五、參考文獻-7六、源代碼-8七、運行情況16C+語言程序設計報告一、 需求分析用C+編寫下面程序?qū)W生成績統(tǒng)計管理系統(tǒng)(*)要求實現(xiàn)如下功能: 成績的輸入(學號、姓名、英語、數(shù)學、C+語言)。 成績統(tǒng)計(各科平均成績、各科成績“優(yōu)秀”、“良

2、好”、“中等”、“及格"、“不及格"的人數(shù)及其所占比例). 總成績統(tǒng)計(學生的總成績、平均成績及成績排名)。 成績的統(tǒng)計結(jié)果顯示。 學生數(shù)據(jù)的添加、修改、與刪除。 學生數(shù)據(jù)的讀取與存儲。二、 概要設計主要數(shù)據(jù)定義以及各程序模塊的功能: Student類中:class Studentprivate: int id;/學號 string name;/姓名 double score3; int x;/指示是否存儲了數(shù)據(jù) double all;/總成績 int rank;/名次 string dengji;/等級public: Student();/構(gòu)造函數(shù) void SetStu

3、dentID(int);/輸入學生學號 int StudentID();/返回學生學號 void SetStudentName(string str);/輸入學生姓名 string StudentName();/返回學生姓名 void SetStudentScore(double y,double s,double c);/輸入學生成績 double StudentYscore();/返回學生英語成績 double StudentSscore();/返回學生數(shù)序成績 double StudentCscore();/返回學生C+成績 void SetStudentX(int n);/給判定學生數(shù)

4、據(jù)存在與否的X賦值 void Getall();/計算學生總成績 void SetRank();/給學生名次值加1 int Rank();/返回學生名次值 int StudentX();/返回判定X的值,判定是否修改 void RankClear();/給學生的名次賦值為1 void Setdengji(string dengji);/輸入等級 double All();/返回學生總成績 string StudentDengji();/返回學生等級值;Studentifo類中:class Studentifoprivate: int num;/學生個數(shù) Student stu;/定義指向存儲學

5、生類的指針public: Studentifo(int n);/構(gòu)造函數(shù) void LoadID(int n);/輸入學生學號 void LoadName(int ,string name);/輸入學生姓名 void LoadScore(int ,double,double,double);/輸入學生各科成績 void Setifo();/插入學生數(shù)據(jù) void Putifo();/輸出所有學生數(shù)據(jù) void Clear();/清除所有學生數(shù)據(jù) void PutID();/輸出指定學生數(shù)據(jù) void ClearID();/刪除指定學生數(shù)據(jù) void MakeRank();/給所有學生排名 vo

6、id ReSetifo();/修改指定學生數(shù)據(jù) void ClearRank();/給指定學生的名次值賦為1 void MakeAll();/計算各個學生的總成績 void PutifoRank();/按名次輸出所有學生數(shù)據(jù) int ID(int n);/返回學生學號 double Yscore(int);/返回學生英語成績 double Sscore(int);/返回學生數(shù)學成績 double Cscore(int);/返回學生C+成績 double StudentAll(int n);/返回學生總成績 int StudentRank(int n);/返回學生名次 string Name(i

7、nt);/返回學生名次 int X(int);/指定X值,確定是否有存儲數(shù)據(jù) string Dengji(int n);/返回學生等級 void Numadd();/num值加1 void Xfix(int);/將指定學生的X指示值賦為1Studentifo();/析構(gòu)函數(shù)釋放new創(chuàng)建的空間;類外:void DoMenu(int n,Studentifot);/將類里的各個函數(shù)組合起來實現(xiàn)各個功能,按指定數(shù)字執(zhí)行void Load(Studentifo *S);/從文件中載入學生信息void Save(Studentifo S);/將學生信息保存到文件void ShowTip(); /顯示操

8、作提示void ShowMenu(); /顯示菜單主函數(shù)的程序流程圖開始輸出菜單及提示信息輸入功能數(shù)字1N 2YN 3清除學生數(shù)據(jù)YN 4插入學生數(shù)據(jù)NNYY 5刪除指定學生數(shù)據(jù) 6N7Y Y 超找指定學生數(shù)據(jù)修改指定學生數(shù)據(jù)按名次輸出學生信息 8N 9 輸出所有學生綜合信息載入數(shù)據(jù)10退出保存 結(jié)束 三 程序?qū)崿F(xiàn)思路本程序通過Studentifo類開辟一個Student的類數(shù)組用已儲存學生數(shù)據(jù)。通過Studentifo類的公有函數(shù)和Student的公有函數(shù)進行關聯(lián),對Student類里的私有學生數(shù)據(jù)進行操作,達到輸入,處理,輸出學生數(shù)據(jù)的功能。同時利用文件輸入輸出流在項目文件夾中創(chuàng)建一個da

9、te。txt文檔進行學生數(shù)據(jù)的保存與讀取。四 設計總結(jié)(1)擺正心態(tài),不心浮氣躁 剛拿到題目,難免會覺得特別迷茫,無從下手,這時如果心浮氣躁則會更加的覺得困難重重。但當我擺正心態(tài),靜小心來慢慢思考的時候,一個個的思路不斷的的冒出,頭腦中的想法遠比實踐過的多。此時,困難已不是從何下手,而是如何下手會是程序更趨完美。(2)一鼓作氣,個個擊破一旦開始了編程后,就要一鼓作氣的繼續(xù)下去。選擇個個擊破,然后將所有的程序在組合起來,很快主程序的雛形就能展現(xiàn)出來,接下來的就只是一點點的修改關聯(lián)是的小錯誤了。用不了多久任務即可完成,特有成就感。但是如果斷斷續(xù)續(xù)的則會在每次編的時候被冗雜而繁多的定義弄糊涂,從而沒

10、有心情繼續(xù)下去。(3)有目的地修改、完善運行時會出現(xiàn)一些錯誤,但我發(fā)現(xiàn)其實里面的參數(shù)并不復雜,只要跟著那個error的提示,一個一個的改下去,其實很簡單的。結(jié)果事實也是如此,看完書后,只用了一個小時多一點,102個錯誤全部搞定了。錯誤幾乎為以下三類:1. 冒號,分號等符號打錯了;2. 大小寫等造成的對應問題;3. 變量的不完全修改.改完以后,在執(zhí)行時我發(fā)現(xiàn)界面不好看,于是我又將主界面略加修改了些??瓷先ッ烙^了不少。再運行功能,前四個都能順利運行,但對百分比餅狀圖我傻眼了。不管我輸入數(shù)據(jù)與否,輸入了什么數(shù)據(jù),結(jié)果都是一樣的,相當離譜。我又糊涂了,搞不清是怎么回事。于是,又去問同學,在他們的幫助下

11、,成功解決這個問題,在此真要好好謝謝他們!終于大功告成!欣慰在這次實踐中,我不僅彌補了自己在C+課上所落下的內(nèi)容,尤其是指針那塊部分,雖然現(xiàn)在概念搞的還不是很懂,但看見程序是能夠理解的。這次C+實踐是給我們這一學期來所學知識的一個總復習,總的實踐。它讓我們把所知道的知識點運用的更好,把不知道的知識點搞得明白了.實踐出真知,通過這次實踐,我也系統(tǒng)的把課本好好的回顧了下。猛然覺得,C+二級考試也有些把握了。五 參考文獻譚浩強. C+程序設計. 清華大學出版社, 2007。5六 源程序main.cpp/* 課程設計題目:學生信息管理系統(tǒng) 班級:0901 學號:200905002109 姓名:譚鄱侖

12、*/include”student.h”int main() int i=0; char ok; Studentifo stuifo; Studentifo *ifo=stuifo; ShowMenu(); cout<”選擇對應數(shù)字進行操作:" while(i!=9) cin>>i; system("cls”); ShowMenu(); DoMenu(i,ifo); ShowTip(); if(flag) cout”數(shù)據(jù)已改動,是否保存Y/N" cin>>ok; if(ok='Y|ok=y') ifo->Make

13、All(); ifo-ClearRank(); ifo>MakeRank(); Save(ifo); cout<"數(shù)據(jù)已保存。按任意鍵安全退出"; else cout<<”已安全退出.。.按任意鍵返回"Student.h#ifndef STUDENT_H_INCLUDED#define STUDENT_H_INCLUDEDincludeiostream#includecstdlib>#include<string>#include<fstream>#include<sstream>#include&

14、lt;iomanipusing namespace std;class Studentprivate: int id;/學號 string name;/姓名 double score3; int x;/指示是否存儲了數(shù)據(jù) double all;/總成績 int rank;/名次 string dengji;/等級public: Student();/構(gòu)造函數(shù) void SetStudentID(int);/輸入學生學號 int StudentID();/返回學生學號 void SetStudentName(string str);/輸入學生姓名 string StudentName();/返回

15、學生姓名 void SetStudentScore(double y,double s,double c);/輸入學生成績 double StudentYscore();/返回學生英語成績 double StudentSscore();/返回學生數(shù)序成績 double StudentCscore();/返回學生C+成績 void SetStudentX(int n);/給判定學生數(shù)據(jù)存在與否的X賦值 void Getall();/計算學生總成績 void SetRank();/給學生名次值加1 int Rank();/返回學生名次值 int StudentX();/返回判定X的值,判定是否修改

16、 void RankClear();/給學生的名次賦值為1 void Setdengji(string dengji);/輸入等級 double All();/返回學生總成績 string StudentDengji();/返回學生等級值;class Studentifoprivate: int num;/學生個數(shù) Student *stu;/定義指向存儲學生類的指針public: Studentifo(int n);/構(gòu)造函數(shù) void LoadID(int n);/輸入學生學號 void LoadName(int ,string name);/輸入學生姓名 void LoadScore(i

17、nt ,double,double,double);/輸入學生各科成績 void Setifo();/插入學生數(shù)據(jù) void Putifo();/輸出所有學生數(shù)據(jù) void Clear();/清除所有學生數(shù)據(jù) void PutID();/輸出指定學生數(shù)據(jù) void ClearID();/刪除指定學生數(shù)據(jù) void MakeRank();/給所有學生排名 void ReSetifo();/修改指定學生數(shù)據(jù) void ClearRank();/給指定學生的名次值賦為1 void MakeAll();/計算各個學生的總成績 void PutifoRank();/按名次輸出所有學生數(shù)據(jù) int ID(

18、int n);/返回學生學號 double Yscore(int);/返回學生英語成績 double Sscore(int);/返回學生數(shù)學成績 double Cscore(int);/返回學生C+成績 double StudentAll(int n);/返回學生總成績 int StudentRank(int n);/返回學生名次 string Name(int);/返回學生名次 int X(int);/指定X值,確定是否有存儲數(shù)據(jù) string Dengji(int n);/返回學生等級 void Numadd();/num值加1 void Xfix(int);/將指定學生的X指示值賦為1

19、Studentifo();/析構(gòu)函數(shù)釋放new創(chuàng)建的空間;void DoMenu(int n,Studentifot);/將類里的各個函數(shù)組合起來實現(xiàn)各個功能,按指定數(shù)字執(zhí)行void Load(Studentifo *S);/從文件中載入學生信息void Save(Studentifo S);/將學生信息保存到文件void ShowTip(); /顯示操作提示void ShowMenu(); /顯示菜單include”studentifo.h"#endif / STUDENT_H_INCLUDEDStudentifo.h#ifndef STUDENTIFO_H_INCLUDEDdef

20、ine STUDENTIFO_H_INCLUDEDbool flag=false ;/數(shù)據(jù)是否修改過的標志Student:Student() id=0; name=”; score0=0; score1=0; score2=0; x=2; all=0; rank=1; dengji=”;void Student:SetStudentID(int n) id=n;void Student::SetStudentName(string str) if(str="0") string str1; cout<"輸入姓名:" cin>str1; thi

21、s->name=str1; else thisname=str;void Student::SetStudentScore(double y,double s,double c) if(y!=0|s!=0c!=0) score0=y; score1=s; score2=c; else double a,b,c; cout<<”輸入英語成績:”; cina; cout<"輸入數(shù)學成績:”; cinb; cout”輸入C+成績:"; cinc; score0=a; score1=b; score2=c; int Student::StudentID()

22、return id;string Student:StudentName() return name;double Student:StudentYscore() return score0;double Student::StudentSscore() return score1;double Student::StudentCscore() return score2;void Student::SetStudentX(int n) x=n;int Student::StudentX() return x;void Student::Getall() thisall=0; this->

23、;all=score0+score1+score2; double n; n=all/3; if(0<=n&n<60) this-dengji=”不及格”; else if(60<=n&n70) this->dengji="及格”; else if(70=n&n80) thisdengji="中等”; else if(80<=n&n90) this-dengji="良好" else this-dengji="優(yōu)秀";double Student:All() return a

24、ll;void Student:SetRank() rank+=1;int Student::Rank() return rank;void Student:RankClear() rank=1;void Student::Setdengji(string dengji) this-dengji=dengji;string Student::StudentDengji() return dengji;Studentifo::Studentifo(int n=100) num=0; stu=new Studentn;Studentifo::Studentifo() delete stu;void

25、 Studentifo::Numadd() num+=1;void Studentifo::LoadID(int n) stun。SetStudentID(n);void Studentifo::LoadName(int n,string name) stun.SetStudentName(name);void Studentifo::LoadScore(int n,double y,double s,double c) stun。SetStudentScore(y,s,c);void Studentifo:Setifo() int n; cout<"輸入學號:”; cin&g

26、t;n; if(stun.StudentX()=1|n<=0) cout<<"該學號已有或者學號信息錯誤”<endl; else stun。SetStudentID(n); stun.SetStudentName("0”); stun。SetStudentScore(0,0,0); stun。SetStudentX(1); num+; cout<endl; void Studentifo:Putifo() int i,s1=0,y1=0,c1=0,y2=0,s2=0,c2=0,y3=0,s3=0,c3=0,y4=0,s4=0,c4=0,y5=0

27、,s5=0,c5=0; double Y=0,S=0,C=0; if(num=0) cout<”沒有學生數(shù)據(jù)”<endl; else cout” |*學生綜合信息*|"<endl; cout<" 學號”<"t”"姓名"”t"<"英語"<”t"<”數(shù)學”<”t"<”C+"<"t"<”總成績”<”t"<"名次"<”t”<"等級 ”<

28、;endl; cout<<” *”<endl; for(i=1; i=100; i+) if(stui.StudentX()=1) Y+=stui。StudentYscore(); S+=stui。StudentSscore(); C+=stui.StudentCscore(); cout" | ”<stui。StudentID()<<t; cout<stui.StudentName()<t' cout<<stui.StudentYscore()<<'t; cout<stui。Student

29、Sscore()'t; coutstui。StudentCscore()t' stui.Getall(); coutstui.All()<t; cout<stui.Rank()<<t' cout<stui.StudentDengji(); cout<”t”endl; cout” *”<endl; if(stui.StudentX()=1) if(stui。StudentYscore()>=0stui。StudentYscore()60) y1+; else if(stui.StudentYscore()=60stui.St

30、udentYscore()70) y2+; else if(stui.StudentYscore()>=70stui.StudentYscore()80) y3+; else if (stui.StudentYscore()>=80&&stui。StudentYscore()<90) y4+; else y5+; if(stui。StudentSscore()=0&stui。StudentSscore()60) s1+; else if(stui。StudentSscore()>=60stui。StudentSscore()70) s2+; el

31、se if(stui.StudentSscore()>=70&&stui。StudentSscore()<80) s3+; else if (stui.StudentSscore()>=80&stui.StudentSscore()<90) s4+; else s5+; if(stui。StudentCscore()=0&stui.StudentCscore()60) c1+; else if(stui。StudentCscore()=60&&stui.StudentCscore()<70) c2+; else if

32、(stui.StudentCscore()>=70&stui.StudentCscore()<80) c3+; else if (stui.StudentCscore()>=80stui。StudentCscore()<90) c4+; else c5+; cout<" _”<endl; cout<" |*各科成績信息*”<<endl; cout”t |t"<"t"<”英語"<"tt""數(shù)學"<"tt

33、”C+t |"<endl; cout”t |平均成績t"<<Y/num"tt"S/num<"tt”<C/num<<"t ”<endl; cout<”t |不及格t”<100double(y1)/num”""tt”<100double(s1)/num"%"<"tt"<100*double(c1)/num<<”""t |"<endl; cout<&l

34、t;”t 及格t"<<setprecision(4)<100double(y2)/num<<”"<”tt"<setprecision(4)100double(s2)/num<"%”<"tt"<setprecision(4)100*double(c2)/num<<”%”"t ”<endl; cout<"t |中等t”<<setprecision(4)100*double(y3)/num”%”<”tt”setpreci

35、sion(4)<100double(s3)/num<”%"<<”tt”setprecision(4)100double(c3)/num<<”%”<<”t "<endl; cout<"t |良好t"<<setprecision(4)<100*double(y4)/num<”%""tt”setprecision(4)100double(s4)/num<”%""tt”<setprecision(4)<<100*do

36、uble(c4)/num<<”%”<”t ”endl; cout”t 優(yōu)秀t"setprecision(4)100double(y5)/num<”"<<”tt"setprecision(4)<100double(s5)/num<<”"<<”tt"<setprecision(4)<<100double(c5)/num"%"<"t |"<endl; cout" |_|”<<”n”endl; c

37、out"*各等級人數(shù)*”<<endl; cout<<"成績"<"t"<”優(yōu)秀”<”t”"良好"<”t"<<"中等"<<"t”<"及格"”t"<<”不及格為”<endl; cout<”英語"<”t "<<y5<<"t ”<y4"t "<y3<<”t &qu

38、ot;y2”t "y1endl; cout"數(shù)學"<”t ”<<s5<<"t "<s4<”t ”<<s3<<”t "<s2"t ”<<s1<endl; cout<<”C+ ”<<”t ”<c5<”t "<<c4"t "c3<”t "<c2<”t "<c1<endl; cout<”*"<en

39、dl; void Studentifo:PutifoRank() if(num=0) cout”沒有學生數(shù)據(jù)"<endl; else cout”名次"<<”t"<<"姓名"<”t”英語"<"t""數(shù)學”<”t"<<”C+"<”t"”總成績”<"t"<"學號”<”t"”等級"<<endl; for(int n=1; n=num; n+

40、) for(int i=1; i<=100; i+) if(stui.StudentX()=1&&stui。Rank()=n) stui.Getall(); cout<<stui.Rank()t; cout<stui。StudentName()<<t'; cout<stui.StudentYscore()<<t; coutstui.StudentSscore()<'t'; cout<stui。StudentCscore()<<t; cout<stui.All()t'

41、; cout<<stui。StudentID()<'t; coutstui.StudentDengji(); cout<endl; void Studentifo::PutID() int n,i,k=0; string str2;pick: cout” *”<<endl; cout<" 1:按學號查找"<endl; cout” *2:按姓名查找*”<endl; cout<” 3:退出查找 ”<endl; cout<<” *”<<endl; cout<"請選擇:

42、”; cini; switch(i) case 1: cout<"輸入學號:" cin>>n; if(stun.StudentX()=2) cout”錯誤!不存在該學生"<endl; goto pick; else cout<”學號”<<"t”姓名"<"t”<<”英語”"t"<”數(shù)學"<”t"<<”C+"<<"t”<<”總成績"<<"t”

43、<"名次"<<"t"<<"等級”endl; cout<<stun。StudentID()<t; cout<stun。StudentName()<t'; cout<<stun。StudentYscore()<'t'; cout<stun。StudentSscore()t; coutstun。StudentCscore()<'t; stun。Getall(); cout<stun.All()<'t; cout

44、<<stun。Rank()<'t; cout<stun。StudentDengji(); cout<endl; break; case 2: cout<”輸入姓名:" cin>str2; cout<”學號”<"t""姓名”<”t"<<"英語”"t”<<"數(shù)學"<<”t”<<"C+”<"t”<<"總成績”<"t"<”名次"<<"t"<”等級”<<endl; for(int j=1; j<=100; j+) if(stuj.StudentName()=str2&&stuj。StudentX()=1) cout<stun。StudentID()t'; cout<<stun.StudentName()<<

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論