版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、湖南科技學院課程設計報告課程名稱:計算機高級語言(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 SetStudentID(int);/輸入學生學號
3、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ù)據(jù)存在與否的X賦值 void Getal
4、l();/計算學生總成績 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;/定義指向存儲學生類的指針public: Studen
5、tifo(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();/給所有學生排名 void ReSetifo();/修改指定
6、學生數(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(int);/返回學生名次 int X(i
7、nt);/指定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,Studentifo*t);/將類里的各個函數(shù)組合起來實現(xiàn)各個功能,按指定數(shù)字執(zhí)行void Load(Studentifo *S);/從文件中載入學生信息void Save(Studentifo *S);/將學生信息保存到文件void ShowTip(); /顯示操作提示void ShowMenu(
8、); /顯示菜單主函數(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ù)進行關(guān)聯(lián),對Student類里的私有學生數(shù)據(jù)進行操作,達到輸入,處理,輸出學生數(shù)據(jù)的功能。同時利用文件輸入輸出流在項目文件夾中創(chuàng)建一個date.txt文檔進行學生數(shù)據(jù)的保存
9、與讀取。四 設計總結(jié)(1)擺正心態(tài),不心浮氣躁 剛拿到題目,難免會覺得特別迷茫,無從下手,這時如果心浮氣躁則會更加的覺得困難重重。但當我擺正心態(tài),靜小心來慢慢思考的時候,一個個的思路不斷的的冒出,頭腦中的想法遠比實踐過的多。此時,困難已不是從何下手,而是如何下手會是程序更趨完美。(2)一鼓作氣,個個擊破一旦開始了編程后,就要一鼓作氣的繼續(xù)下去。選擇個個擊破,然后將所有的程序在組合起來,很快主程序的雛形就能展現(xiàn)出來,接下來的就只是一點點的修改關(guān)聯(lián)是的小錯誤了。用不了多久任務即可完成,特有成就感。但是如果斷斷續(xù)續(xù)的則會在每次編的時候被冗雜而繁多的定義弄糊涂,從而沒有心情繼續(xù)下去。(3)有目的地修改
10、、完善運行時會出現(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 姓名:譚鄱侖 */#includestudent
12、.hint main() int i=0; char ok; Studentifo stuifo; Studentifo *ifo=&stuifo; ShowMenu(); couti; system(cls); ShowMenu(); DoMenu(i,ifo); ShowTip(); if(flag) coutok; if(ok=Y|ok=y) ifo-MakeAll(); ifo-ClearRank(); ifo-MakeRank(); Save(ifo); cout數(shù)據(jù)已保存.按任意鍵安全退出; else cout已安全退出.按任意鍵返回;Student.h#ifndef STUDEN
13、T_H_INCLUDED#define STUDENT_H_INCLUDED#include#include#include#include#include#includeusing 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 StudentI
14、D();/返回學生學號 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ù)據(jù)存在與否的X賦值 void Getall();/計算學生總成績
15、 void SetRank();/給學生名次值加1 int Rank();/返回學生名次值 int StudentX();/返回判定X的值,判定是否修改 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 Lo
16、adID(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();/給所有學生排名 void ReSetifo();/修改指定學生數(shù)據(jù) void ClearRank();/給指
17、定學生的名次值賦為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(int);/返回學生名次 int X(int);/指定X值,確定是否有存儲數(shù)據(jù) strin
18、g Dengji(int n);/返回學生等級 void Numadd();/num值加1 void Xfix(int);/將指定學生的X指示值賦為1 Studentifo();/析構(gòu)函數(shù)釋放new創(chuàng)建的空間;void DoMenu(int n,Studentifo*t);/將類里的各個函數(shù)組合起來實現(xiàn)各個功能,按指定數(shù)字執(zhí)行void Load(Studentifo *S);/從文件中載入學生信息void Save(Studentifo *S);/將學生信息保存到文件void ShowTip(); /顯示操作提示void ShowMenu(); /顯示菜單#includestudentifo.
19、h#endif / STUDENT_H_INCLUDEDStudentifo.h#ifndef STUDENTIFO_H_INCLUDED#define 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=
20、0) string str1; coutstr1; this-name=str1; else this-name=str;void Student:SetStudentScore(double y,double s,double c) if(y!=0|s!=0|c!=0) score0=y; score1=s; score2=c; else double a,b,c; couta; coutb; coutc; score0=a; score1=b; score2=c; int Student:StudentID() return id;string Student:StudentName()
21、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() this-all=0; this-all=score0+score1+score2; double n; n=all/3; i
22、f(0=n&ndengji=不及格; else if(60=n&ndengji=及格; else if(70=n&ndengji=中等; else if(80=n&ndengji=良好; else this-dengji=優(yōu)秀;double Student:All() return all;void Student:SetRank() rank+=1;int Student:Rank() return rank;void Student:RankClear() rank=1;void Student:Setdengji(string dengji) this-dengji=dengji;str
23、ing Student:StudentDengji() return dengji;Studentifo:Studentifo(int n=100) num=0; stu=new Studentn;Studentifo:Studentifo() delete stu;void Studentifo:Numadd() num+=1;void Studentifo:LoadID(int n) stun.SetStudentID(n);void Studentifo:LoadName(int n,string name) stun.SetStudentName(name);void Studenti
24、fo:LoadScore(int n,double y,double s,double c) stun.SetStudentScore(y,s,c);void Studentifo:Setifo() int n; coutn; if(stun.StudentX()=1|n=0) cout該學號已有或者學號信息錯誤endl; else stun.SetStudentID(n); stun.SetStudentName(0); stun.SetStudentScore(0,0,0); stun.SetStudentX(1); num+; coutendl; void Studentifo:Puti
25、fo() 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,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ù)學tC+t總成績t名次t等級 |endl; cout |*|endl; for(i=1; i=100; i+) if(stui.StudentX()=1) Y+=stui.StudentYscore(); S+=stui.StudentSscore
26、(); C+=stui.StudentCscore(); cout | stui.StudentID()t; coutstui.StudentName()t; coutstui.StudentYscore()t; coutstui.StudentSscore()t; coutstui.StudentCscore()t; stui.Getall(); coutstui.All()t; coutstui.Rank()t; coutstui.StudentDengji(); coutt|endl; cout |*|=0&stui.StudentYscore()=60&stui.StudentYsco
27、re()=70&stui.StudentYscore()=80&stui.StudentYscore()=0&stui.StudentSscore()=60&stui.StudentSscore()=70&stui.StudentSscore()=80&stui.StudentSscore()=0&stui.StudentCscore()=60&stui.StudentCscore()=70&stui.StudentCscore()=80&stui.StudentCscore()90) c4+; else c5+; cout _endl; cout |*各科成績信息*|endl; coutt
28、|tt英語tt數(shù)學ttC+t |endl; coutt |平均成績tY/numttS/numttC/numt |endl; coutt |不及格t100*double(y1)/num%tt100*double(s1)/num%tt100*double(c1)/num%t |endl; coutt |及格tsetprecision(4)100*double(y2)/num%ttsetprecision(4)100*double(s2)/num%ttsetprecision(4)100*double(c2)/num%t |endl; coutt |中等tsetprecision(4)100*dou
29、ble(y3)/num%ttsetprecision(4)100*double(s3)/num%ttsetprecision(4)100*double(c3)/num%t |endl; coutt |良好tsetprecision(4)100*double(y4)/num%ttsetprecision(4)100*double(s4)/num%ttsetprecision(4)100*double(c4)/num%t |endl; coutt |優(yōu)秀tsetprecision(4)100*double(y5)/num%ttsetprecision(4)100*double(s5)/num%tt
30、setprecision(4)100*double(c5)/num%t |endl; cout |_|nendl; cout*各等級人數(shù)*endl; cout成績t優(yōu)秀t良好t中等t及格t不及格為endl; cout英語t y5t y4t y3t y2t y1endl; cout數(shù)學t s5t s4t s3t s2t s1endl; coutC+ t c5t c4t c3t c2t c1endl; cout*endl; void Studentifo:PutifoRank() if(num=0) cout沒有學生數(shù)據(jù)endl; else cout名次t姓名t英語t數(shù)學tC+t總成績t學號t等級
31、endl; for(int n=1; n=num; n+) for(int i=1; i=100; i+) if(stui.StudentX()=1&stui.Rank()=n) stui.Getall(); coutstui.Rank()t; coutstui.StudentName()t; coutstui.StudentYscore()t; coutstui.StudentSscore()t; coutstui.StudentCscore()t; coutstui.All()t; coutstui.StudentID()t; coutstui.StudentDengji(); coute
32、ndl; void Studentifo:PutID() int n,i,k=0; string str2;pick: cout *endl; cout *1:按學號查找*endl; cout *2:按姓名查找*endl; cout *3:退出查找 *endl; cout *endl; couti; switch(i) case 1: coutn; if(stun.StudentX()=2) cout錯誤!不存在該學生endl; goto pick; else cout學號t姓名t英語t數(shù)學tC+t總成績t名次t等級endl; coutstun.StudentID()t; coutstun.StudentName()t; coutstun.StudentYscore()t; coutstun.StudentSscore()t; coutstun.StudentCscore()t; stun.Getall(); coutstun.All()t; coutstun.Rank()t; coutstun.StudentDengji(); coutendl; break; case 2: coutstr2; cout學號t姓名t英語t數(shù)學tC+t總成績t名次t等
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 范本指南留置擔保合同
- 個人服務合同
- 房地產(chǎn)銷售合作合同協(xié)議書范本
- 美容師實習生聘用合同
- 紗線采購合同模板
- 個人過橋資金借款合同
- 工程施工合同協(xié)議書范文
- 暖通工程承包合同
- 環(huán)境衛(wèi)生承包合同范本
- 長期供貨合同范本
- 2024-2025學年北京市豐臺區(qū)高三語文上學期期末試卷及答案解析
- 公路電子收費系統(tǒng)安裝合同范本
- 2021年全國高考物理真題試卷及解析(全國已卷)
- 綜合實踐項目 制作水族箱飼養(yǎng)淡水魚 教學設計-2024-2025學年魯科版生物六年級上冊
- 建設用地土壤污染風險評估技術(shù)導則(HJ 25.3-2019代替HJ 25.3-2014)
- JJG 692-2010無創(chuàng)自動測量血壓計
- 徐州市2023-2024學年八年級上學期期末地理試卷(含答案解析)
- 飲料對人體的危害1
- 數(shù)字經(jīng)濟學導論-全套課件
- 中考記敘文閱讀
- 產(chǎn)科溝通模板
評論
0/150
提交評論