C++學(xué)生成績統(tǒng)計管理系統(tǒng) 增刪減修改統(tǒng)計 繼承派生_第1頁
C++學(xué)生成績統(tǒng)計管理系統(tǒng) 增刪減修改統(tǒng)計 繼承派生_第2頁
C++學(xué)生成績統(tǒng)計管理系統(tǒng) 增刪減修改統(tǒng)計 繼承派生_第3頁
C++學(xué)生成績統(tǒng)計管理系統(tǒng) 增刪減修改統(tǒng)計 繼承派生_第4頁
C++學(xué)生成績統(tǒng)計管理系統(tǒng) 增刪減修改統(tǒng)計 繼承派生_第5頁
已閱讀5頁,還剩29頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、 南 昌 大 學(xué)C+ 選 修 課課程設(shè)計報告 題 目:C+學(xué)生成績統(tǒng)計管理系統(tǒng) 學(xué) 院:機(jī)電工程學(xué)院專 業(yè):15級動力工程專業(yè)姓 名:梁帥帥 學(xué) 號:415914215045 電 話2016年6月17日目錄 1需求分析32概要設(shè)計33程序?qū)崿F(xiàn)思路44設(shè)計總結(jié)45參考文獻(xiàn)56源代碼6一、需求分析經(jīng)過研一下學(xué)期C+選修課的學(xué)習(xí),對C+基于對象的程序設(shè)計有了一定的認(rèn)識,根據(jù)所學(xué)的知識,設(shè)計學(xué)生成績管理系統(tǒng)。學(xué)生成績統(tǒng)計管理系統(tǒng)是為某班級成績統(tǒng)計管理的一個系統(tǒng)。為方便班級的管理人員對學(xué)生的信息進(jìn)行管理,該系統(tǒng)中包括學(xué)號、姓名、大學(xué)物理、高數(shù)、C+語言,各科平均成績、各科成績“

2、優(yōu)秀”、“良好”、“中等”、“及格”、“不及格”的人數(shù)及其所占比例,學(xué)生的總成績、平均成績及成績排名。通過仔細(xì)研究借鑒眾多相關(guān)畢業(yè)設(shè)計研究等文獻(xiàn)資料(見參考文獻(xiàn)一),學(xué)習(xí)書籍譚浩強面向?qū)ο蟮腃+程序設(shè)計編寫了該成績管理系統(tǒng)。主要的功能有學(xué)生數(shù)據(jù)的增加、刪除、修改、查詢,另外實現(xiàn)一些統(tǒng)計的功能,例如:成績的輸入、成績統(tǒng)計、總成績統(tǒng)計、成績的統(tǒng)計結(jié)果顯示。二、概要設(shè)計1、本程序所用到的所有抽象數(shù)據(jù)類型的定義如下:序號成員名數(shù)據(jù)類型含義1numlong學(xué)號2namestring姓名3sumdouble總分4rangeint排名5avedouble平均分6scoredouble記錄數(shù)組2、各程序模塊的

3、功能void input(); /輸入void count(); /計算void sort(); /按學(xué)號升序排列void selectsort(); /按總成績降序排列void insert(); /增加int del(); /刪除void student:Exit(); /修改void search(); /查詢void display(); /顯示以下為統(tǒng)計模塊:void count(); /計算成員函數(shù)void average(); /計算平均值成員函數(shù)void display(); /顯示成員函數(shù) 三、程序?qū)崿F(xiàn)思路1.設(shè)計菜單實現(xiàn)功能成績的輸入(學(xué)號、姓名、大學(xué)物理、高數(shù)、C+語言)

4、。成績統(tǒng)計(各科平均成績、各科成績“優(yōu)秀”、“良好”、“中等”、“及格”、“不及格”的人數(shù)及其所占比例)??偝煽兘y(tǒng)計(學(xué)生的總成績、平均成績及成績排名)。成績的統(tǒng)計結(jié)果顯示。學(xué)生數(shù)據(jù)的增加、修改、與刪除。學(xué)生數(shù)據(jù)的讀取與存儲。2.設(shè)計類與對象class student /建立學(xué)生student類,目的是存儲學(xué)生個人信息public:long num; /學(xué)號string name; /姓名double scoren; /學(xué)生科目成績 double sum; /總成績double ave; /平均成績int range; /排名 void insert(); /增加 int del(); /刪除

5、void search(); /查詢void student:Exit();/修改void display(); /顯示void input(); /輸入void count(); /計算void sort(); /按學(xué)號升序排列void selectsort(); /按總成績降序排列stuN;class all /建立整體all類,目的是存放學(xué)生整體信息public: double ave; /每學(xué)科的平均成績 int people5; /每學(xué)科的各等級人數(shù) double percent5; /每學(xué)科的各等級人數(shù)比例void count(); /計算成員函數(shù) void average();

6、/計算平均值成員函數(shù) void display(); /顯示成員函數(shù) aln;3.通過類的調(diào)用實現(xiàn)功能設(shè)計case 0:cout<<"*"<<endl;cout<<"高數(shù)科統(tǒng)計結(jié)果為"<<endl;cout<<"*"<<endl;cout<<endl;break;case 1:cout<<"*"<<endl;cout<<"大學(xué)物理科統(tǒng)計結(jié)果為"<<endl;cout

7、<<"*"<<endl;cout<<endl;break;case 2:cout<<"*"<<endl;cout<<"C+統(tǒng)計結(jié)果為"<<endl;cout<<"*"<<endl;cout<<endl;break;case 3:if(total=0) cout<<"數(shù)組為空,請在主菜單中選擇1增加數(shù)據(jù)"<<endl;else cout<<&q

8、uot;學(xué)生信息為:"<<endl; stutotal.count(); stutotal.display();/顯示 cout<<endl; break;case 4:if (total=0) cout<<"數(shù)組為空,請在主菜單中選擇1增加數(shù)據(jù)"<<endl;elsecout<<"各科學(xué)生成績?yōu)?"<<endl;aln.average();aln.count(); aln.display();cout<<endl;break;case 5:if(total=0

9、) cout<<"數(shù)組為空,請在主菜單中選擇1增加數(shù)據(jù)"<<endl;elsedo stutotal.search();cout<<"查詢成功,繼續(xù)查詢請輸入Y/y:"<<endl; cout<<"退出請按其他鍵"<<endl; fflush(stdin); ch=getchar();while(ch='Y'|ch='y');break;case 6:if(total=0) cout<<"數(shù)組為空,請在主菜單中

10、選擇1增加數(shù)據(jù)"<<endl;elsedostutotal.Exit(); /修改cout<<"修改成功,繼續(xù)修改請輸入Y/y:"<<endl;cout<<"退出請按其他鍵"<<endl;fflush(stdin);ch=getchar();while(ch='Y'|ch='y');break;case 7:if(total=0) cout<<"數(shù)組為空,請在主菜單中選擇1增加數(shù)據(jù)"<<endl;else do

11、 system("cls"); stutotal.insert(); /增加 total+; cout<<"增加成功,繼續(xù)增加請輸入Y/y:"<<endl; cout<<"退出請按其他鍵"<<endl; fflush(stdin); ch=getchar(); cout<<endl;while(ch='Y'|ch='y');break;case 8:if(total=0)cout<<"數(shù)組為空,請在主菜單中選擇1增加數(shù)據(jù)&

12、quot;<<endl;elsedo system("cls"); if(stutotal.del() /刪除 total-; /人數(shù)-1 system("cls"); else cout<<"該學(xué)號不存在"<<endl; system("pause"); system("cls"); cout<<"刪除成功,繼續(xù)刪除請輸入Y/y:"<<endl; cout<<"退出該選擇請按其他鍵"

13、<<endl; fflush(stdin); ch=getchar(); cout<<endl;while(ch='Y'|ch='y'); break;case 9: cout<<"此操作將刪除所有記錄"<<endl; cout<<"繼續(xù)該操作請輸入Y/y:"<<endl; cout<<"退出請按其他鍵"<<endl; fflush(stdin); ch=getchar(); if(ch='Y'

14、;|ch='y') total=0; break;default:cout<<"確定要退出嗎?"<<endl; cout<<"退出請輸入Y/y:"<<endl; fflush(stdin); ch=getchar(); cout<<endl; if(ch='y'|ch='Y') exit(0); break; system("pause"); while(1);四、設(shè)計總結(jié)通過為期兩周的努力,挑戰(zhàn)程序設(shè)計的難度,終于將程序正確地

15、運行。雖說只是一個簡單的程序,但它卻見證了我從編寫、調(diào)試、修改、運行、再修改等一系列的過程,收錄了我努力后的小小成果。從不斷調(diào)試中遇到的錯誤中,我發(fā)現(xiàn)了自己的不足,同時也學(xué)會讓自己如何面對挑戰(zhàn)。 運用結(jié)構(gòu)體、類等新學(xué)的內(nèi)容讓我再次感受到了學(xué)習(xí)的重要性。都說“萬變不離其宗”,書本是我們課后學(xué)習(xí)的參照。因為沒有重視書本,讓我在編譯時不斷翻看,這也堅定了我努力學(xué)好這門課程的決心。 五、參考文獻(xiàn) 1.譚浩強C+程序設(shè)計清華出版社 2007,5六、源代碼學(xué)生成績統(tǒng)計管理程序#include<iostream> /引用庫函數(shù)#include<iomanip> /引用控制符處理#in

16、clude<string> /字符串using namespace std;#define N 100 /宏定義#define n 3class student /建立學(xué)生類,用于存儲學(xué)生個人信息public:long num; /學(xué)號string name; /姓名double scoren; /學(xué)生科目成績double sum; /總成績double ave; /平均成績int range; /排名void input(); /輸入void count(); /計算void sort(); /按學(xué)號升序排列void selectsort(); /按總成績降序排列void sea

17、rch(); /查詢void insert(); /增加int del(); /刪除void student:Exit(); /修改數(shù)據(jù)void display(); /顯示stuN;class all /建立整體類,用來存放學(xué)生整體信息public:double ave; /每學(xué)科的平均成績int people5; /每學(xué)科的各等級人數(shù)double percent5; /每學(xué)科的各等級人數(shù)比例void count(); /計算成員函數(shù)void average(); /計算平均值成員函數(shù)void display(); /顯示成員函數(shù)aln;int total=0; /定義全局變量void st

18、udent:input() /輸入學(xué)生個人信息cout<<"請輸入學(xué)生信息:"<<endl;cout<<"學(xué)號"<<setw(8)<<"姓名"<<setw(12)<<"高數(shù)成績"<<setw(10)<<"大學(xué)物理成績"<<setw(10)<<"C+成績"<<endl;cin>>setw(10)>>stutota

19、l.num;cin>>setw(10)>>;for(int j=0;j<n;j+)cin>>setw(10)>>stutotal.scorej;void student:selectsort() /按總成績降序排列student aa;int i,j;for(i=0;i<total-1;i+)for(j=i+1;j<total;j+)if(stui.sum<stuj.sum) aa=stuj;stuj=stui;stui=aa;void student:count() /計算總成績、平均成績stu

20、total.selectsort();for(int i=0;i<total;i+)stui.sum=0;for(int j=0;j<n;j+)stui.sum+=stui.scorej;stui.ave=stui.sum/n;void student:sort() /按學(xué)號升序排列student abc;int i,j;for(i=0;i<total-1;i+)for(j=i+1;j<total;j+)if(stui.num>stuj.num)abc=stuj;stuj=stui;stui=abc;void student:display() /顯示學(xué)生個人信息

21、selectsort(); /調(diào)用按總成績降序排列函數(shù)cout<<"學(xué)號"<<setw(10)<<"姓名"<<setw(10)<<"高數(shù)成績"<<setw(10)<<"大學(xué)物理成績"<<setw(10)<<"C+成績"<<setw(10)<<"平均成績"<<setw(10)<<"總成績"<<

22、setw(10)<<"排名"<<endl;for(int i=0;i<total;i+)stui.range=i+1;cout<<setw(10)<<stui.num<<setw(10)<<;for(int j=0;j<n;j+)cout<<setw(10)<<stui.scorej;cout<<setw(10)<<stui.ave<<setw(10)<<stui.sum<<setw(10)

23、<<stui.range<<endl;void all:average() /計算各科的平均成績for(int j=0;j<n;j+)long double a=0;for(int i=0;i<total;i+) a+=stui.scorej;alj.ave=a/double(total);void all:count() /計算各科的各等級人數(shù)及其比例for(int j=0;j<n;j+)int a=0,b=0,c=0,d=0,e=0;for(int i=0;i<total;i+)if(stui.scorej<60)a+;else if(

24、stui.scorej<70)b+;else if(stui.scorej<80)c+;else if(stui.scorej<90)d+;elsee+;alj.people0=a; /高數(shù)科不及格人數(shù)alj.people1=b; /高數(shù)科及格人數(shù)alj.people2=c; /高數(shù)科中等人數(shù)alj.people3=d; /高數(shù)科良好人數(shù)alj.people4=e; /高數(shù)科優(yōu)秀人數(shù)alj.percent0=a/double(total); /高數(shù)科不及格人數(shù)所占的比例alj.percent1=b/double(total); /高數(shù)科及格人數(shù)所占的比例alj.percent

25、2=c/double(total); /高數(shù)科中等人數(shù)所占的比例alj.percent3=d/double(total); /高數(shù)科良好人數(shù)所占的比例alj.percent4=e/double(total); /高數(shù)科優(yōu)秀人數(shù)所占的比例void all:display( ) /輸出整體信息for(int j=0; j<n; j+)switch(j)case 0:cout<<"*"<<endl;cout<<"高數(shù)科統(tǒng)計結(jié)果為"<<endl;cout<<"*"<<

26、;endl;cout<<endl;break;case 1:cout<<"*"<<endl;cout<<"大學(xué)物理科統(tǒng)計結(jié)果為"<<endl;cout<<"*"<<endl;cout<<endl;break;case 2:cout<<"*"<<endl;cout<<"C+統(tǒng)計結(jié)果為"<<endl;cout<<"*"<

27、<endl;cout<<endl;break;cout<<"平均成績?yōu)?"<<alj.ave<<endl;cout<<endl;cout<<"不及格人數(shù)為:"<<alj.people0<<endl;cout<<"及格人數(shù)為:"<<alj.people1<<endl;cout<<"中等人數(shù)為:"<<alj.people2<<endl;cout&l

28、t;<"良好人數(shù)為:"<<alj.people3<<endl;cout<<"優(yōu)秀人數(shù)為:"<<alj.people4<<endl;cout<<"不及格人數(shù)為:"<<alj.percent0<<endl;cout<<"及格人數(shù)比為:"<<alj.percent1<<endl;cout<<"中等人數(shù)為:"<<alj.percent2<

29、<endl;cout<<"良好人數(shù)比為:"<<alj.percent3<<endl;cout<<"優(yōu)秀人數(shù)比為:"<<alj.percent4<<endl;cout<<endl;void student:search() /查詢int find_num;bool flag=false;cout<<"請輸入要查找的學(xué)生的學(xué)號"<<endl;cin>>find_num;for(int i=0;i<total;

30、i+)if(stui.num=find_num) /如果要找的學(xué)號與其中某一個學(xué)生的學(xué)號相同cout<<setw(10)<<stui.num<<endl;cout<<"已經(jīng)找到該學(xué)生信息,他的有關(guān)信息是:"<<endl;cout<<setw(10)<<;for(int j=0;j<n;j+)cout<<setw(10)<<stui.scorej;cout<<setw(10)<<stui.ave<<setw(1

31、0)<<setw(10)<<stui.sum<<setw(10)<<stui.range<<endl; /輸出學(xué)生信息flag=true;break; if(flag=false)cout<<"找不到該學(xué)生的學(xué)號"<<endl; /如找不到輸出"找不到"信息void student:Exit() /修改int ID;bool flag=false;string name1;cout<<"請輸入要修改的學(xué)生的信息"<<endl;c

32、out<<setw(12)<<"學(xué)號:"<<setw(12)<<endl;cout<<"姓名:"<<setw(12)<<endl;cout<<"高數(shù)成績:"<<setw(12)<<endl;cout<<"大學(xué)物理成績:"<<setw(12)<<endl;cout<<"C+成績:"<<endl;cin>>ID

33、;cin>>name1;for(int i=0;i<total;i+)if(stui.num=ID)stui.num=ID;=name1;flag=true;break;if(flag=false)cout<<"找不到該學(xué)生的學(xué)號"<<endl;void student:insert() /增加int a;string aa;double x,y,z;stutotal.sort(); /調(diào)用按學(xué)號升序排列函數(shù)cout<<"請輸入要增加的學(xué)生的信息"<<endl; /輸入要

34、增加學(xué)生的信息cout<<setw(12)<<"學(xué)號"<<setw(12)<<"姓名"<<setw(12)<<"高數(shù)成績"<<setw(12)<<"大學(xué)物理成績"<<setw(12)<<"C+成績"<<endl;cin>>a>>aa>>x>>y>>z;stutotal.num=a;

35、=aa;stutotal.score0=x;stutotal.score1=y;stutotal.score2=z;int student:del() /刪除int i,j,abc;cout<<"請輸入要刪除的學(xué)號:"<<endl;cin>>abc;stutotal.sort(); /調(diào)用按學(xué)號升序排列函數(shù)for(i=0;i<total;i+)if(abc=stui.num) /如果某一個學(xué)生的學(xué)號與要刪除的學(xué)生的學(xué)號相同break;if(i<total)for(j=i;j<total;j+)stuj=stuj+1;re

36、turn 1;elsereturn 0;void menu(); /顯示主菜單class student;class all;void student:display();void all:display(); /顯示學(xué)生信息void student:insert(); /增加學(xué)生(自動排序)int student:del(); /刪除學(xué)生void student:search(); /按學(xué)號查詢int main() /主函數(shù)class student stuN;class all aln;char ch;int select; /total為學(xué)生總數(shù),select為選擇dosystem(&q

37、uot;cls");menu();cout<<"請輸入你的選擇:"<<endl;fflush(stdin);cin>>select;system("cls");switch(select)case 1:dosystem("cls");stutotal.input();total+; /人數(shù)+1cout<<"輸入成功,繼續(xù)輸入請輸入Y/y:"<<endl;cout<<"退出請輸入其他鍵"<<endl;ff

38、lush(stdin);ch=getchar();while(ch='Y'|ch='y');cout<<endl;break;case 2:if(total=0)cout<<"數(shù)組為空,請在主菜單中選擇1增加數(shù)據(jù)"<<endl;elsecout<<"學(xué)生信息為:"<<endl;stutotal.count();stutotal.display(); /顯示cout<<endl;break;case 3:if(total=0)cout<<&q

39、uot;數(shù)組為空,請在主菜單中選擇1增加數(shù)據(jù)"<<endl;elsecout<<"各科學(xué)生成績?yōu)?"<<endl;aln.average();aln.count();aln.display();cout<<endl;break;case 4:if(total=0)cout<<"數(shù)組為空,請在主菜單中選擇1增加數(shù)據(jù)"<<endl;elsedostutotal.search();cout<<"查詢成功,繼續(xù)查詢請輸入Y/y:"<<en

40、dl;cout<<"退出請按其他鍵"<<endl;fflush(stdin);ch=getchar();while(ch='Y'|ch='y');break;case 5:if(total=0)cout<<"數(shù)組為空,請在主菜單中選擇1增加數(shù)據(jù)"<<endl;elsedostutotal.Exit(); /修改cout<<"修改成功,繼續(xù)修改請輸入Y/y:"<<endl;cout<<"退出請按其他鍵"

41、<<endl;fflush(stdin);ch=getchar();while(ch='Y'|ch='y');break;case 6:if(total=0)cout<<"數(shù)組為空,請在主菜單中選擇1增加數(shù)據(jù)"<<endl;elsedosystem("cls");stutotal.insert(); /增加total+;cout<<"增加成功,繼續(xù)增加請輸入Y/y:"<<endl;cout<<"退出請按其他鍵"&

42、lt;<endl;fflush(stdin);ch=getchar();cout<<endl;while(ch='Y'|ch='y');break;case 7:if(total=0)cout<<"數(shù)組為空,請在主菜單中選擇1增加數(shù)據(jù)"<<endl;elsedosystem("cls");if(stutotal.del() /刪除total-; /人數(shù)-1system("cls");elsecout<<"該學(xué)號不存在"<<endl;system(&q

溫馨提示

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

評論

0/150

提交評論