当前位置:文档之家› C++奖学金评定系统课设报告

C++奖学金评定系统课设报告

沈阳航空航天大学实验报告课程名称:面向对象程序设计及C++实验题目:学生奖学金评定系统院(系):计算机学院专业:计算机科学与技术班级:学号:姓名:一、实验目的达到对所学面向对象程序设计知识的一次综合运用,熟练掌握面象对象分析问题、解决问题的方法。

二、实验内容描述该实验室评定学生奖学金的一个系统,包括查看学生奖学获得的情况,以及录入学生信息,修改学生信息,查看个人奖学金等功能。

结果都将保存在文件中,在下次程序开始时会自动调用上一次修改的结果。

三、类设计及描述四、关键函数描述初始化学生信息函数chushihua();:把文件中已有的学生信息读取出来查寻学生获得奖学金信息函数paihang();:查询所有学生奖学金获得情况录入学生成绩函数fun1();:录入新学生姓名,性别,学号,以及成绩修改学生成绩函数amend();:可以修改已有学生任何一次考试的任何一门成绩查寻个人奖学金函数find();:可以查寻已有学生奖学金获得的情况。

五、程序测试/运行的结果图4.1******************查询文件中已有学生信息********************图4.2************************初始化学生信息***************************图4.3*******************查询学生获得奖学金信息************************图4.4******************** 查询结果 ************************图4.5**********************如果没有录入此人信息**************六、实验总结这是我第一次做比较大的C++程序,在制作的过程中遇到过很多问题,不过还在在老师和同学的帮助下把这些问题都得到了解决。

程序可以流畅运行,但是依然存在着很多缺陷,比如说界面,做的并没有呢么完美,功能方面也有待加强,我会继续努力,争取做出更好的作品。

附录(实验代码)#include<iostream>#include<math.h>#include<string>#include<fstream>using namespace std;static int n=0;class exam //成绩类{public:float Math;float English;float Sport;float practise;float zong;};class final:public exam{public:float zongchengji(float a=0,float b=0,float c=0,float d=0); };class midterm:public exam{public:float zongchengji(float a=0,float b=0,float c=0,float d=0); };float midterm::zongchengji(float a,float b,float c,float d){zong=a+b+c+d;return a+b+c+d;}float final::zongchengji(float a,float b,float c,float d){zong=a+b+c+d;return a+b+c+d;}class student //学生类{public:float pingding();public:string name; //姓名string number; //学号char sex[5]; //性别int money; //奖学金数额float GPA; //绩点midterm zhong; //期中考试成绩final mo; //期末考试成绩};float student::pingding(){float a,b;a=(mo.Math*4+mo.English*3+mo.Sport*2+mo.practise*1.5)*0.7/10.5/10;b=(zhong.English*3.5+zhong.Math*4+zhong.practise*1.5+zhong.Sport*2)*0.3/10.5/10;GPA=a+b;if(GPA>=8)money=1000;else if(GPA>=7&&GPA<8)money=500;else if(GPA>=6&&GPA<7)money=300;else if(GPA<6&&GPA>=5)money=150;elsemoney=0;return GPA;;}class guanli{public:void print();int gameprint1();void fun1(student *stu);void paihang(student *stu);void find(student *stu);void amend(student *stu);void chushi(student *stu);};void guanli::print() //打印界面函数{cout<<"┃------------------------------------┃"<<endl;cout<<"┃********* 奖学金评定*********┃"<<endl;cout<<"┃********* 1初始化学生信息*********┃"<<endl;cout<<"┃********* 2查看奖学金信息*********┃"<<endl;cout<<"┃********* 3查询个人奖学金*********┃"<<endl;cout<<"┃********* 4修改个人成绩*********┃"<<endl;cout<<"┃********* 5退出*********┃"<<endl;cout<<"┃------------------------------------┃"<<endl;}int guanli::gameprint1() //打印函数{int a;cout<<"继续操作请按1,退出请按0"<<endl;cin>>a;return a;}void guanli::chushi(student *stu) //初始化学生信息函数{ifstream p;int i;p.open("E:\\基本信息.txt");if(!p){cout<<"打开失败"<<endl;exit(0);}while(!p.eof()){p>>stu[n].name>>stu[n].number>>stu[n].sex>>stu[n].mo.Math>>stu[n].mo.English>>stu[n]. mo.Sport>>stu[n].mo.practise>>stu[n].zhong.Math>>stu[n].zhong.English>>stu[n].zhong.Sport> >stu[n].zhong.practise;n++;}for(i=0;i<n;i++)stu[i].pingding();p.close();}void guanli::fun1(student *stu) //录入学生信息函数{float a,b,c,d,i;cout<<"输入学生姓名,学号,性别"<<endl;cin>>stu[n].name>>stu[n].number>>stu[n].sex;cout<<"请选择输入"<<stu[n].name<<"的成绩"<<endl;cout<<"请输入该生期中成绩--请按--数学英语体育实践的顺序输入,否则默认为0"<<endl;cin>>a>>b>>c>>d;stu[n].zhong.Math=a;stu[n].zhong.English=b;stu[n].zhong.Sport=c;stu[n].zhong.practise=d;stu[n].zhong.zongchengji(a,b,c,d);cout<<"请输入该生期末考试成绩--请按--数学英语体育实践的顺序输入,否则默认为0"<<endl;cin>>a>>b>>c>>d;stu[n].mo.Math=a;stu[n].mo.English=b;stu[n].mo.Sport=c;stu[n].mo.practise=d;stu[n].mo.zongchengji(a,b,c,d);ofstream p;p.open("E:\\基本信息.txt",ios::app);if(!p){cout<<"打开失败"<<endl;exit(0);}p<<endl<<stu[n].name<<" "<<stu[n].number<<" "<<stu[n].sex<<stu[n].mo.Math<<" "<<stu[n].mo.English<<" "<<stu[n].mo.Sport<<" "<<stu[n].mo.practise<<" "<<stu[n].zhong.Math<<" "<<stu[n].zhong.English<<" "<<stu[n].zhong.Sport<<" "<<stu[n].zhong.practise;n++;}void guanli::paihang(student *stu) //查看奖学金信息函数{int i;cout<<"姓名"<<" "<<"绩点"<<" "<<"奖学金数额"<<endl;for(i=0;i<n;i++){stu[i].pingding();cout<<stu[i].name<<" "<<stu[i].GPA<<" "<<stu[i].money<<endl;}}void guanli::find(student *stu) //查询奖学金函数{int a;float b;cout<<"请输入所查询学生学号"<<endl;string ch;cin>>ch;int i;for(i=0;i<n;i++){if(ch==stu[i].number){b=stu[i].pingding();if(b>=6&&b<7)cout<<"恭喜"<<stu[i].name<<"获得综合三等奖学金,数额为300"<<endl;else if(b>=5&&b<6)cout<<"恭喜"<<stu[i].name<<"获得单项奖学金,数额为150"<<endl;else if(b>=7&&b<8)cout<<"恭喜"<<stu[i].name<<"获得综合二等奖学金,数额为500"<<endl;else if(b>=8)cout<<"恭喜"<<stu[i].name<<"获得综合一等奖学金,数额为1000"<<endl;elsecout<<"该生未获得奖学金,请继续努力"<<endl;return ;}}cout<<"查无此人"<<endl;}void guanli::amend(student *stu) //修改学生成绩函数{string s;int i=0,a,b;char ch;float aa;cout<<"请输入修改学生的姓名"<<endl;cin>>s;for(i=0;i<n;i++)if(stu[i].name==s){ofstream p;p.open("E:\\基本信息.txt");if(!p){cout<<"打开失败"<<endl;exit(0);}loop1: cout<<"请输入要修改的成绩"<<endl;cout<<" 1期中"<<endl;cout<<" 2期末"<<endl;cin>>a;if(a==1){cout<<"请输入要修改的学科"<<endl;cout<<" 1数学"<<endl;cout<<" 2英语"<<endl;cout<<" 3体育"<<endl;cout<<" 4实践"<<endl;cin>>b;cout<<"请输入修改后的成绩"<<endl;cin>>aa;switch(b){case 1:stu[i].zhong.Math=aa;break;case 2:stu[i].zhong.English=aa;break;case 3:stu[i].zhong.Sport=aa;break;case 4:stu[i].zhong.practise=aa;break;}}else if(a==2){cout<<"请输入要修改的学科"<<endl;cout<<" 1数学"<<endl;cout<<" 2英语"<<endl;cout<<" 3体育"<<endl;cout<<" 4实践"<<endl;cin>>b;cout<<"请输入修改后的成绩"<<endl;cin>>aa;switch(b){case 1:stu[i].mo.Math=aa;break;case 2:stu[i].mo.English=aa;break;case 3:stu[i].mo.Sport=aa;break;case 4:stu[i].mo.practise=aa;break;}}else{cout<<"输入错误请重新输入"<<endl;goto loop1;}cout<<"继续修改?<y\n>"<<endl;cin>>ch;if(ch=='y')goto loop1;for(i=0;i<n;i++){p<<stu[n].name<<" "<<stu[n].number<<" "<<stu[n].sex<<stu[n].mo.Math<<" "<<stu[n].mo.English<<" "<<stu[n].mo.Sport<<" "<<stu[n].mo.practise<<" "<<stu[n].zhong.Math<<" "<<stu[n].zhong.English<<" "<<stu[n].zhong.Sport<<" "<<stu[n].zhong.practise;}p.close();return;}cout<<"查无此人"<<endl;}void main(){system("color 8c");student stu[100],*CH;guanli a;CH=stu;a.chushi(stu);int i,lin;loop1: a.print();cin>>i;if(i!=1&&i!=2&&i!=3&&i!=4&&i!=5){cout<<"输入错误,请重新输入"<<endl;goto loop1;}else{switch(i){case 1:a.fun1(CH);lin=a.gameprint1();if(lin==1)goto loop1;else exit(0);case 2:a.paihang(CH);lin=a.gameprint1();if(lin==1)goto loop1;else exit(0);case 3:a.find(CH);lin=a.gameprint1();if(lin==1)goto loop1;else exit(0);case 4:a.amend(CH);lin=a.gameprint1();if(lin==1)goto loop1;else exit(0);case 5: exit(0);}}}。

相关主题