《C++学生信息管理系统课程设计报告.pdf》由会员分享,可在线阅读,更多相关《C++学生信息管理系统课程设计报告.pdf(45页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、面向对象的程序设计面向对象的程序设计课程设计报告课程设计报告姓姓名:名:学学号:号:班班级:级:院院系系日期:日期:目录1 课程设计目的2 项目规定与简介3 设计题目题目学生成绩管理系统4 测试运营的结果.5 心得体会与进一步的改善6 参考书目7 源代码 程序设计语言(程序设计语言(C+C+)课程设计课程设计一一设设计目的计目的1.1.进一步掌握用进行类的定义和操作进一步掌握用进行类的定义和操作2.2.进一步掌握类的继承和派生进一步掌握类的继承和派生3.3.掌握在掌握在 Visual C+6Visual C+6 进行编程的技术进行编程的技术4.4.综合运用上述知识,编写面向对象的简朴程序综合运
2、用上述知识,编写面向对象的简朴程序5.5.培养团结合作能力和自主学习的能力培养团结合作能力和自主学习的能力二二项项目规定与简介目规定与简介1.1.规定系统具有一定的存储记忆功能规定系统具有一定的存储记忆功能2.2.规定系统可以解决常见异常并作出反映规定系统可以解决常见异常并作出反映3.3.系统具有常用的学生信息解决功能系统具有常用的学生信息解决功能4.4.本系统还处在本系统还处在 1.11.1 版本,还会发布后续版本版本,还会发布后续版本三三设设计题目计题目题目题目学生成绩管理系统学生成绩管理系统(一)(一).系统的重要功能系统的重要功能1.1.增长学生增长学生系统可以提醒用户输入增长的学生个
3、数,添入到系统可以提醒用户输入增长的学生个数,添入到 student.datstudent.dat2.2.删除删除一方面由用户输入要删除的位置,然后系统调用删除函数一方面由用户输入要删除的位置,然后系统调用删除函数3.3.查找查找系统提醒用户输入要查找的学号,成绩,姓名然后系统再传递用户系统提醒用户输入要查找的学号,成绩,姓名然后系统再传递用户选择的项目分别调用以上三个函数选择的项目分别调用以上三个函数4.4.修改修改系统提醒用户要修改的位置,然后传递给修改函数。接着系统出现提醒系统提醒用户要修改的位置,然后传递给修改函数。接着系统出现提醒提醒用户修改的项目,可以修改学号,姓名或者成绩提醒用户
4、修改的项目,可以修改学号,姓名或者成绩5.5.成绩信息成绩信息用户选择该功能以后,系统出现提醒。总共有六项,求平均成绩用户选择该功能以后,系统出现提醒。总共有六项,求平均成绩,成绩排序成绩排序低于平均成绩的学生信息,高于低于平均成绩的学生信息,高于 9090 分的学生信息,低于分的学生信息,低于 6060 分的学生信息或分的学生信息或退出该功能退出该功能6.6.显示所有学生信息显示所有学生信息调用此功能,系统读取文献中当前所有内容输出调用此功能,系统读取文献中当前所有内容输出7.7.当前学生总数当前学生总数读取读取 long.txtlong.txt 中保存的信息并输出中保存的信息并输出8.8.
5、互换两个学生信息互换两个学生信息调用函数互换两个学生的信息调用函数互换两个学生的信息9.9.插入学生信息插入学生信息在指定位置新建一个学生信息,位置由用户输入在指定位置新建一个学生信息,位置由用户输入(二)(二).系统总体框架系统总体框架开始界面重要提醒的菜单界面新建学生删除学生修改信息学生总数查找信息成绩信息互换信息(三)(三).系统数据结构定义系统数据结构定义class student/这是数据节点public:student();student(student&c)this-number=c.getnumber();this-setname(c.getname();this-setsex
6、(c.getsex();void setname(char*name1)void setnumber(int num)void setgrade(double grade1)this-number=num;strcpy(this-name,name1);this-grade=c.getgrade();this-grade=grade1;void setsex(char*sex1)char*getname()double getgrade()int getnumber()char*getsex()return this-sex;return this-number;return this-gra
7、de;return this-name;strcpy(this-sex,sex1);private:;char name20;char sex5;double grade;int number;四四测测试运营的结果试运营的结果测试新建学生信息功能测试新建学生信息功能测试查看学生总数功能测试查看学生总数功能测试插入学生信息功能测试插入学生信息功能测试显示所有学生信息功能测试显示所有学生信息功能测试学生成绩信息功能测试学生成绩信息功能测试互换学生信息功能测试互换学生信息功能测试删除学生信息功能测试删除学生信息功能测试修改学生信息功能测试修改学生信息功能测测试试查查找找学学生生信信息息功功能能五五心
8、心得体会与进一步改善得体会与进一步改善通过本次 VC课程设计,我了解了 Visual C6 的调试和找错基本方法。系统的设计基本实现了老师所规定的功能,同时还增添加了互换学生信息的新功能。同时在设计过程中,对于系统的功能尚有许多不完善的地方,例如为了是对输入信息的限制,没有在系统中做限制用户可以随意输入,由此也许导致系统犯错。此外对于删除没有实现按学号删除,因此还需要更多的设计来完善对于表达式的解决;设计一开始是以链表为基础的,后来进行不下去了。重新用了现在 C中对文献解决的知识;界面风格只是使用默认的,没有创新,这个需要在以后的设计中加以改善。本次的课程设计让自己在学习新知识上有了更高的理解
9、,有些只是只有在你想到要用时才会自己去学,同时自己在编程上的理解更深一层,逐步了解编程在实际中的运用,掌握了更多编程方法和思想,拓宽了知识面,为进一步的学习继续打牢根基。六六参参考书目考书目Visualc+Visualc+入门到精通入门到精通七七源源代码代码class list:public studentclass list:public studentpublic:public:v void display()oid display()ifstream infile;ifstream infile;int a=1;int a=1;infile.open(student.dat,ios:bi
10、nary);infile.open(student.dat,ios:binary);student c;student c;while(infile.read(char*)&c,sizeof(c)while(infile.read(char*)&c,sizeof(c)infile.close();infile.close();coutcout第第aa个学生信息个学生信息endl;endl;coutcout姓名:姓名:c.getname()endl;c.getname()endl;coutcout性别:性别:c.getsex()endl;c.getsex()endl;coutcout成绩:成绩:
11、c.getgrade()endl;c.getgrade()endl;coutcout学号学号:c.getnumber()endl;:c.getnumber()endl;a+;a+;coutendl;coutendl;/显示学生信息显示学生信息v void write(int i)oid write(int i)int a,t,b=0;int a,t,b=0;char name120;char name120;char sex15;char sex15;int number1;int number1;double grade1;double grade1;ofstream outfile;ofs
12、tream outfile;outfile.open(student.dat,ios:app);outfile.open(student.dat,ios:app);student c;student c;for(a=1;a=i;a+)for(a=1;a=i;a+)coutcoutname1;cinname1;c.setname(name1);c.setname(name1);coutcoutnumber1;cinnumber1;c.setnumber(number1);c.setnumber(number1);coutcoutsex1;cinsex1;c.setsex(sex1);c.sets
13、ex(sex1);coutcoutgrade1;cingrade1;c.setgrade(grade1);c.setgrade(grade1);outfile.write(char*)&c,sizeof(c);outfile.write(char*)&c,sizeof(c);outfile.close();outfile.close();ifstream infile;ifstream infile;/infile.seekg(0,ios:end);/infile.seekg(0,ios:end);infile.open(long.txt);infile.open(long.txt);if(i
14、nfile.is_open()if(infile.is_open()while(!infile.eof()while(!infile.eof()else else infile.close();infile.close();ofstream outfile1(long.txt);ofstream outfile1(long.txt);t=i+b;t=i+b;outfile1t;outfile1cap1;infilecap1;infile.close();infile.close();student c;student c;ifstream infile1(student.dat);ifstre
15、am infile1(student.dat);ofstream outfile(temp.dat);ofstream outfile(temp.dat);int a;int a;for(a=1;ai;a+)for(a=1;ai;a+)outfile.close();outfile.close();infile1.close();infile1.close();ifstream infile2(student.dat);ifstream infile2(student.dat);infile2.seekg(sizeof(c)*(i-1);infile2.seekg(sizeof(c)*(i-1
16、);infile2.read(char*)&c,sizeof(c);infile2.read(char*)&c,sizeof(c);char name120;char name120;coutcoutname1;cinname1;c.setnumber(c.getnumber();c.setnumber(c.getnumber();c.setgrade(c.getgrade();c.setgrade(c.getgrade();c.setname(name1);c.setname(name1);c.setsex(c.getsex();c.setsex(c.getsex();ofstream ou
17、tfile1(temp.dat,ios:app);ofstream outfile1(temp.dat,ios:app);outfile1.write(char*)&c,sizeof(c);outfile1.write(char*)&c,sizeof(c);outfile1.close();outfile1.close();ifstream infile3(student.dat);ifstream infile3(student.dat);infile3.seekg(sizeof(c)*i);infile3.seekg(sizeof(c)*i);ofstream outfile2(temp.
18、dat,ios:app);ofstream outfile2(temp.dat,ios:app);for(a=i+1;a=cap1;a+)for(a=i+1;a=cap1;a+)outfile2.close();outfile2.close();infile3.close();infile3.close();ifstream infile4(temp.dat);ifstream infile4(temp.dat);ofstream outfile3(student.dat);ofstream outfile3(student.dat);for(a=1;a=cap1;a+)for(a=1;aca
19、p1;infilecap1;infile.close();infile.close();student c;student c;ifstream infile1(student.dat);ifstream infile1(student.dat);ofstream outfile(temp.dat);ofstream outfile(temp.dat);int a;int a;for(a=1;ai;a+)for(a=1;ai;a+)outfile.close();outfile.close();infile1.close();infile1.close();ifstream infile2(s
20、tudent.dat);ifstream infile2(student.dat);infile2.seekg(sizeof(c)*(i-1);infile2.seekg(sizeof(c)*(i-1);infile2.read(char*)&c,sizeof(c);infile2.read(char*)&c,sizeof(c);infile1.read(char*)&c,sizeof(c);infile1.read(char*)&c,sizeof(c);outfile.write(char*)&c,sizeof(c);outfile.write(char*)&c,sizeof(c);int
21、number1;int number1;coutcoutnumber1;cinnumber1;c.setnumber(number1);c.setnumber(number1);c.setgrade(c.getgrade();c.setgrade(c.getgrade();c.setname(c.getname();c.setname(c.getname();c.setsex(c.getsex();c.setsex(c.getsex();ofstream outfile1(temp.dat,ios:app);ofstream outfile1(temp.dat,ios:app);outfile
22、1.write(char*)&c,sizeof(c);outfile1.write(char*)&c,sizeof(c);outfile1.close();outfile1.close();ifstream infile3(student.dat);ifstream infile3(student.dat);infile3.seekg(sizeof(c)*i);infile3.seekg(sizeof(c)*i);ofstream outfile2(temp.dat,ios:app);ofstream outfile2(temp.dat,ios:app);for(a=i+1;a=cap1;a+
23、)for(a=i+1;a=cap1;a+)outfile2.close();outfile2.close();infile3.close();infile3.close();ifstream infile4(temp.dat);ifstream infile4(temp.dat);ofstream outfile3(student.dat);ofstream outfile3(student.dat);for(a=1;a=cap1;a+)for(a=1;acap1;infilecap1;infile.close();infile.close();student c;student c;ifst
24、ream infile1(student.dat);ifstream infile1(student.dat);ofstream outfile(temp.dat);ofstream outfile(temp.dat);int a;int a;for(a=1;ai;a+)for(a=1;ai;a+)outfile.close();outfile.close();infile1.close();infile1.close();ifstream infile2(student.dat);ifstream infile2(student.dat);infile1.read(char*)&c,size
25、of(c);infile1.read(char*)&c,sizeof(c);outfile.write(char*)&c,sizeof(c);outfile.write(char*)&c,sizeof(c);infile2.seekg(sizeof(c)*(i-1);infile2.seekg(sizeof(c)*(i-1);infile2.read(char*)&c,sizeof(c);infile2.read(char*)&c,sizeof(c);char sex15;char sex15;coutcoutsex1;cinsex1;c.setnumber(c.getnumber();c.s
26、etnumber(c.getnumber();c.setgrade(c.getgrade();c.setgrade(c.getgrade();c.setname(c.getname();c.setname(c.getname();c.setsex(sex1);c.setsex(sex1);ofstream outfile1(temp.dat,ios:app);ofstream outfile1(temp.dat,ios:app);outfile1.write(char*)&c,sizeof(c);outfile1.write(char*)&c,sizeof(c);outfile1.close(
27、);outfile1.close();ifstream infile3(student.dat);ifstream infile3(student.dat);infile3.seekg(sizeof(c)*i);infile3.seekg(sizeof(c)*i);ofstream outfile2(temp.dat,ios:app);ofstream outfile2(temp.dat,ios:app);for(a=i+1;a=cap1;a+)for(a=i+1;a=cap1;a+)outfile2.close();outfile2.close();infile3.close();infil
28、e3.close();ifstream infile4(temp.dat);ifstream infile4(temp.dat);ofstream outfile3(student.dat);ofstream outfile3(student.dat);infile3.read(char*)&c,sizeof(c);infile3.read(char*)&c,sizeof(c);outfile2.write(char*)&c,sizeof(c);outfile2.write(char*)&c,sizeof(c);for(a=1;a=cap1;a+)for(a=1;acap1;infilecap
29、1;infile.close();infile.close();student c;student c;ifstream infile1(student.dat);ifstream infile1(student.dat);ofstream outfile(temp.dat);ofstream outfile(temp.dat);int a;int a;for(a=1;ai;a+)for(a=1;ai;a+)outfile.close();outfile.close();infile1.read(char*)&c,sizeof(c);infile1.read(char*)&c,sizeof(c
30、);outfile.write(char*)&c,sizeof(c);outfile.write(char*)&c,sizeof(c);infile1.close();infile1.close();ifstream infile2(student.dat);ifstream infile2(student.dat);infile2.seekg(sizeof(c)*(i-1);infile2.seekg(sizeof(c)*(i-1);infile2.read(char*)&c,sizeof(c);infile2.read(char*)&c,sizeof(c);double grade1;do
31、uble grade1;coutcoutgrade1;cingrade1;c.setnumber(c.getnumber();c.setnumber(c.getnumber();c.setgrade(grade1);c.setgrade(grade1);c.setname(c.getname();c.setname(c.getname();c.setsex(c.getsex();c.setsex(c.getsex();ofstream outfile1(temp.dat,ios:app);ofstream outfile1(temp.dat,ios:app);outfile1.write(ch
32、ar*)&c,sizeof(c);outfile1.write(char*)&c,sizeof(c);outfile1.close();outfile1.close();ifstream infile3(student.dat);ifstream infile3(student.dat);infile3.seekg(sizeof(c)*i);infile3.seekg(sizeof(c)*i);ofstream outfile2(temp.dat,ios:app);ofstream outfile2(temp.dat,ios:app);for(a=i+1;a=cap1;a+)for(a=i+1
33、;a=cap1;a+)outfile2.close();outfile2.close();infile3.close();infile3.close();infile3.read(char*)&c,sizeof(c);infile3.read(char*)&c,sizeof(c);outfile2.write(char*)&c,sizeof(c);outfile2.write(char*)&c,sizeof(c);ifstream infile4(temp.dat);ifstream infile4(temp.dat);ofstream outfile3(student.dat);ofstre
34、am outfile3(student.dat);for(a=1;a=cap1;a+)for(a=1;acap1;infilecap1;infile.close();infile.close();student c;student c;ifstream infile1(student.dat);ifstream infile1(student.dat);if(i=cap1)if(i=cap1)int j=1;int j=1;while(j!=0)while(j!=0)cout _endl;cout _endl;cout|*cout|*请输入你想执行的操作请输入你想执行的操作*|endl;*|e
35、ndl;cout|*1.cout|*1.修改学生学号修改学生学号 *|endl;*|endl;cout|*2.cout|*2.修改学生姓名修改学生姓名 *|endl;*|endl;cout|*3.cout|*3.修改学生性别修改学生性别 *|endl;*|endl;cout|*4.cout|*4.修改学生成绩修改学生成绩 *|endl;*|endl;cout|*5.cout|*5.显示该学生信息显示该学生信息 *|endl;*|endl;cout|*0.cout|*0.cout coutendl;j;cinj;switch(j)switch(j)case 1:case 1:this-modif
36、y1(i,j);this-modify1(i,j);break;break;case 2:case 2:this-modify2(i,j);this-modify2(i,j);break;break;case 3:case 3:this-modify3(i,j);this-modify3(i,j);break;break;case 4:case 4:this-modify4(i,j);this-modify4(i,j);break;break;case 5:case 5:退出操作退出操作 *|endl;*|endl;infile1.seekg(sizeof(c)*(i-1);infile1.s
37、eekg(sizeof(c)*(i-1);infile1.read(char*)&c,sizeof(c);infile1.read(char*)&c,sizeof(c);cout cout第第ii个学生信息个学生信息endl;endl;cout cout姓名:姓名:c.getname()endl;c.getname()endl;cout cout性别:性别:c.getsex()endl;c.getsex()endl;cout cout成绩:成绩:c.getgrade()endl;c.getgrade()endl;cout cout学号学号:c.getnumber()endl;:c.getnum
38、ber()endl;break;break;case 0:case 0:break;break;else else cout cout你修改的位置有误你修改的位置有误endl;j)if(ij)t=i;t=i;i=j;i=j;j=t;j=t;student b;student b;ifstream infile;ifstream infile;infile.open(long.txt);infile.open(long.txt);infilecap1;infilecap1;infile.close();infile.close();if(i!=j)if(i!=j)if(i=cap1&j=cap1
39、)if(i=cap1&jDelete(i);b=this-Delete(i);this-insert(j-1,b);this-insert(j-1,b);b=this-Delete(j);b=this-Delete(j);this-insert(i,b);this-insert(i,b);/互换两学生信息互换两学生信息 void sort()void sort()int cap1,i,j;int cap1,i,j;student a,b;student a,b;ifstream infile;ifstream infile;infile.open(long.txt);infile.open(l
40、ong.txt);infilecap1;infilecap1;infile.close();infile.close();for(i=0;icap1-1;i+)for(i=0;icap1-1;i+)for(j=i+1;jcap1;j+)for(j=i+1;jcap1;j+)ifstream infile1(student.dat);ifstream infile1(student.dat);ifstream infile2(student.dat);ifstream infile2(student.dat);infile1.seekg(sizeof(a)*(i);infile1.seekg(s
41、izeof(a)*(i);infile1.read(char*)&a,sizeof(a);infile1.read(char*)&a,sizeof(a);infile2.seekg(sizeof(b)*(j);infile2.seekg(sizeof(b)*(j);infile2.read(char*)&b,sizeof(b);infile2.read(char*)&b,sizeof(b);if(a.getgrade()=b.getgrade()if(a.getgrade()change(i+1,j+1);this-change(i+1,j+1);infile1.close();infile1
42、.close();infile2.close();infile2.close();/从大到小排列成绩从大到小排列成绩 void insert(int i,student b)void insert(int i,student b)int cap1;int cap1;ifstream infile;ifstream infile;infile.open(long.txt);infile.open(long.txt);infilecap1;infilecap1;infile.close();infile.close();if(i=cap1)if(i=cap1)student c;student c
43、;ifstream infile1(student.dat);ifstream infile1(student.dat);ofstream outfile(temp.dat);ofstream outfile(temp.dat);int a;int a;for(a=1;ai;a+)for(a=1;ai;a+)outfile.close();outfile.close();infile1.close();infile1.close();ofstream outfile1(temp.dat,ios:app);ofstream outfile1(temp.dat,ios:app);outfile1.
44、write(char*)&b,sizeof(b);outfile1.write(char*)&b,sizeof(b);outfile1.close();outfile1.close();ifstream infile2(student.dat);ifstream infile2(student.dat);infile2.seekg(sizeof(c)*(i-1);infile2.seekg(sizeof(c)*(i-1);ofstream outfile2(temp.dat,ios:app);ofstream outfile2(temp.dat,ios:app);for(a=i;a=cap1;
45、a+)for(a=i;a=cap1;a+)outfile2.close();outfile2.close();infile2.close();infile2.close();ifstream infile3(temp.dat);ifstream infile3(temp.dat);ofstream outfile3(student.dat);ofstream outfile3(student.dat);infile2.read(char*)&c,sizeof(c);infile2.read(char*)&c,sizeof(c);outfile2.write(char*)&c,sizeof(c)
46、;outfile2.write(char*)&c,sizeof(c);infile1.read(char*)&c,sizeof(c);infile1.read(char*)&c,sizeof(c);outfile.write(char*)&c,sizeof(c);outfile.write(char*)&c,sizeof(c);for(a=1;a=cap1+1;a+)for(a=1;a=cap1+1;a+)remove(temp.dat);remove(temp.dat);cap1+;cap1+;infile3.close();infile3.close();outfile3.close();
47、outfile3.close();ofstream outfile4(long.txt);ofstream outfile4(long.txt);outfile4cap1;outfile4cap1;outfile4.close();outfile4.close();infile3.read(char*)&c,sizeof(c);infile3.read(char*)&c,sizeof(c);outfile3.write(char*)&c,sizeof(c);outfile3.write(char*)&c,sizeof(c);elseelsecoutcout你输入的插入位置有误你输入的插入位置有
48、误endl;cap1;infile1cap1;infile1.close();infile1.close();student c,b;student c,b;ifstream infile2(student.dat,ios:binary);ifstream infile2(student.dat,ios:binary);int a;int a;ofstream outfile1(temp1.dat);ofstream outfile1(temp1.dat);for(a=1;ai;a+)for(a=1;ai;a+)infile2.read(char*)&c,sizeof(c);infile2.r
49、ead(char*)&c,sizeof(c);outfile1.write(char*)&c,sizeof(c);outfile1.write(char*)&c,sizeof(c);infile2.seekg(sizeof(c)*(i-1);infile2.seekg(sizeof(c)*(i-1);infile2.read(char*)&c,sizeof(c);infile2.read(char*)&c,sizeof(c);b=c;b=c;infile2.seekg(sizeof(c)*(i);infile2.seekg(sizeof(c)*(i);ofstream outfile2(tem
50、p1.dat,ios:app);ofstream outfile2(temp1.dat,ios:app);for(a=i+1;a=cap1;a+)for(a=i+1;a=cap1;a+)infile2.close();infile2.close();outfile1.close();outfile1.close();outfile2.close();outfile2.close();ofstream outfile3(student.dat);ofstream outfile3(student.dat);ifstream infile3(temp1.dat);ifstream infile3(