收藏 分销(赏)

C学生成绩标准管理系统专业课程设计方案报告.doc

上传人:精*** 文档编号:2727090 上传时间:2024-06-05 格式:DOC 页数:25 大小:80.04KB 下载积分:10 金币
下载 相关 举报
C学生成绩标准管理系统专业课程设计方案报告.doc_第1页
第1页 / 共25页
C学生成绩标准管理系统专业课程设计方案报告.doc_第2页
第2页 / 共25页


点击查看更多>>
资源描述
一.目标和要求 经过本课程设计实践,全方面总结C++课程学习中数据类型、程序结构、数组、函数、指针、结构体、链表等基础概念,掌握其使用方法。掌握面向对象程序设计中相关类、对象、继承、重载、多态性、输入输出流类体系、文件操作基础概念,初步学会用类和对象这种面向对象程序设计方法编写应用程序。培养使用面向对象程序设计方法编写计算机程序能力。 经过设计一个《学生成绩统计管理》,深入熟悉C++中类概念、类封装、继承实现方法。了解系统开发需求分析、类层次设计、模块分解、编码测试、模块组装和整体调试全过程,加深对C++了解和Visual C++环境使用;逐步熟悉程序设计方法,并养成良好编程习惯。程序设计是一门实践性很强课程,必需十分重视实践步骤。很多实际知识不是靠听课和看书学到,而是经过长时间实践积累。 一、 设计内容 学生成绩管理系统 1. 基础功效: 这个程序关键功效是输入学生姓名、成绩,学号,并能够对学生成绩按学号进行查询。该系统含有存贮学生数据,按学号按需要修改学生成绩,列出学生成绩和统计功效。 2. 扩展功效: 学生数据添加、修改、和删除 2.E—R 修改数据 删除数据 查询数据 显示数据 平均数据 添加数据 学生成绩管理系统 二、 过程和结果 关键内容以下: 1. 关键类设计,继承层次关系,代码: 首先,创建了一个student类. Student类申明以下: class Student{ public: int Class,num; char name[8]; float cpp,math,eng,ave; int order; Student *next; public: Student() {} Student(int c1,int n1,char*n,float e1,float c2,float m,float e2,float s,float p,float a, int o,Student *next=NULL) { Class=c1;num=n1; strcpy(name,n); cpp=c2;math=m;eng=e2;ave=a; order=o; this->next=next; } 关键功效函数设计: 1. 创建学生数据,对学生成绩录入。 代码:friend Student *Create(Student *head,istream& in) {int y; Student *p; int Class,num; char name[8]; float cpp,math,eng; if(&in==&cin) //cout<<"\n\n请输入学生数据(输入成绩非法,则结束),数据输入格式为:\n" //<<"班级 姓名 学号 C++ 数学 英语 \n"; //in>>Class>>name>>num>>cpp>>math>>eng; //cout<<"\n\n请输入学生数据:\n" cout<<"班级:"<<endl; in>>Class; cout<<"姓名:"<<endl; in>>name; cout<<"学号:"<<endl; in>>num; cout<<"C++成绩:"<<endl; in>>cpp; cout<<"数学成绩:"<<endl; in>>math; cout<<"英语成绩 :"<<endl; in>>eng; /*while(Valid(elec)&&Valid(cpp)&&Valid(math)&&Valid(eng)&&Valid(sport)&&Valid(polity)) {*/p=new Student; p->Class=Class;p->num=num;strcpy(p->name,name); p->cpp=cpp;p->math=math; p->eng=eng; p->ave=(cpp+math+eng)/6; head=Insert(head,p); //in>>Class>>name>>num>>elec>>cpp>>math>>eng>>polity>>sport; cout<<"\t\t*****继续添加请按1*******\n"; cout<<"\t\t*****返回主菜单请按2*******\n"; in>>y; if(y==2) { ShowMenu(); } else{head=Create(head,cin);} SetOrder(head); //设置排名 return head; } 2. 此函数为查找函数实现过程 关键代码:friend const Student * Lookup(const Student *head,int num) //查找指定学号为num结点 { while(head && head->num!=num) head=head->next; return head; } friend void OutputOne(const Student* head) //输出一个学生数据 { cout<<head->Class<<'\t'<<head->name<<'\t'<<head->num<<'\t' <<head->cpp<<'\t'<<head->math<<'\t' <<head->eng<<'\t' <<head->order<<endl; } 3.此函数为删除函数实现部分。 关键代码:friend Student *DeleteStudent(Student *head,int num) { Student *p1=head,*p2=p1; while(p2&&p2->num!=num) p1=p2,p2=p2->next; if(p2) { if(p2==p1) { head=head->next;delete p1; } else { p1->next=p2->next;delete p2; } cout<<"已删除"<<num<<"号学生数据\n"; SetOrder(head); }else cout<<"没找到指定学生!\n"; return head; } 4.排序函数中平均分来排序,排序结果为降序操作。 friend void SetOrder(Student*head) { int order=1; while(head) {head->order=order++;head=head->next;} } 5.修改学生信息 friend Student *Modify(Student *head,int num) //修改学号为学生数据 { Student *p1=head,*p2=p1; while(p2&&p2->num!=num) //寻求待修改结点 p1=p2,p2=p2->next; if(p2) //修改指定结点数据 { /*cout<<"\n\n请输入新数据,格式为:\n" <<"班级 姓名 学号 C++ 数学 英语 \n"; cin>>p2->Class>>p2->name>>p2->num>>p2->cpp>>p2->math >>p2->eng;*/ cout<<"班级:"<<endl; cin>>p2->Class; cout<<"姓名:"<<endl; cin>>p2->name; cout<<"学号:"<<endl; cin>>p2->num; cout<<"C++成绩:"<<endl; cin>>p2->cpp; cout<<"数学成绩:"<<endl; cin>>p2->math; cout<<"英语成绩 :"<<endl; cin>>p2->eng; while(!Valid(p2->cpp)||!Valid(p2->math)||!Valid(p2->eng) ) { cout<<"\n\n成绩数据非法!请重新输入,格式为:\n" <<"班级 姓名 学号 C++ 数学 英语 \n"; cin>>p2->Class>>p2->name>>p2->num>>p2->cpp>>p2->math >>p2->eng; } p2->ave=(p2->cpp+p2->math+p2->eng)/3; //将修改指定结点从原链表上修改下来,并重新降序插入原链表 if(p2==p1) head=Insert(p2->next,p2); else { p1->next=p2->next; head=Insert(head,p2); } SetOrder(head); } else cout<<"没找到指定学生!\n"; return head; } 6.显示数据: friend void OutputAll(const Student*head) //输出全部学生数据 { if(!head) {cout<<"\n\n\t\t没有任何学生数据!\n\n"; return;} cout<<"\n\n\t\t学生成绩表\n\n"; cout<<"班级\t姓名\t学号\tC++\t数学\t英语\t名次\n"; while(head) { OutputOne(head);head=head->next; } } 7.平均数据函数 friend void Statistic(const Student *head) { int i=0; float ave_cpp=0, ave_math=0, ave_eng=0; while(head) { ave_cpp+=head->cpp; ave_math+=head->math; ave_eng+=head->eng; i++;head=head->next; } if(!i) { cout<<"\n\n没有任何学生数据!\n";return;} cout<<"\n\n\t\t各门课程平均成绩表\n\n"; cout<<"tC++\t数学\t英语\n"; cout<<ave_cpp/i<<'\t'<<ave_math/i<<'\t' <<ave_eng/i<<endl; } 程序测试结果: 1运行程序.会出现以下画面,根据提醒进行选择. 2. 首先选择1,然后按Enter键.根据提醒对学生情况进行输入.图: 3. 按1键能够添加多个学生成绩数据,按2返回主界面。 4. 选择5, 然后按Enter键,显示刚才输入数据和排名情况。 5在主界面选择2能够修改学生数据。 6.在主界面选择3能够按学号查询学生成绩情况 7. 在主界面选择7能够按学号删除学生成绩信息 三、 设计总结 这次课程设计基础上涵盖了学习到C++ 语言知识点,课程设计题目要求不仅要求对书本即使是网上搜来代码,但这些代码没措施运行,我把这些代码改了和增加了自己写代码,最终能够运行,而且抵达自己想要结果,这次课程设计不仅让我修补了以前学习漏洞,也让我知道一个道理:编程需要爱好和实际动手。C++语言程序设计课程设计,我从中受益匪浅,而且对C++语言程序设计这一门课程有了更深一步认识。 附件 程序源代码清单: #include <fstream.h> #include <string.h> class Student{ public: int Class,num; char name[8]; float cpp,math,eng,ave; int order; Student *next; public: Student() {} Student(int c1,int n1,char*n,float e1,float c2,float m,float e2,float s,float p,float a, int o,Student *next=NULL) { Class=c1;num=n1; strcpy(name,n); cpp=c2;math=m;eng=e2;ave=a; order=o; this->next=next; } friend int Valid(float score) { return (score<0||score>100) ?0:1; } friend void SetOrder(Student*head) { int order=1; while(head) {head->order=order++;head=head->next;} } friend Student* Insert(Student *head,Student *p) //在head所指链表中降序插入结点p { Student*p1,*p2; if(head==0) { head=p;p->next=0; } else if(head->ave<=p->ave) { p->next=head;head=p; } else { p2=p1=head; while(p2->next&&p2->ave>p->ave) { p1=p2;p2=p2->next; } if(p2->ave>p->ave) { p2->next=p;p->next=0; } else { p->next=p2;p1->next=p; } } return head; } friend Student *Create(Student *head,istream& in) {int y; Student *p; int Class,num; char name[8]; float cpp,math,eng; if(&in==&cin) //cout<<"\n\n请输入学生数据(输入成绩非法,则结束),数据输入格式为:\n" //<<"班级 姓名 学号 C++ 数学 英语 \n"; //in>>Class>>name>>num>>cpp>>math>>eng; //cout<<"\n\n请输入学生数据:\n" cout<<"班级:"<<endl; in>>Class; cout<<"姓名:"<<endl; in>>name; cout<<"学号:"<<endl; in>>num; cout<<"C++成绩:"<<endl; in>>cpp; cout<<"数学成绩:"<<endl; in>>math; cout<<"英语成绩 :"<<endl; in>>eng; /*while(Valid(elec)&&Valid(cpp)&&Valid(math)&&Valid(eng)&&Valid(sport)&&Valid(polity)) {*/p=new Student; p->Class=Class;p->num=num;strcpy(p->name,name); p->cpp=cpp;p->math=math; p->eng=eng; p->ave=(cpp+math+eng)/6; head=Insert(head,p); //in>>Class>>name>>num>>elec>>cpp>>math>>eng>>polity>>sport; cout<<"\t\t*****继续添加请按1*******\n"; cout<<"\t\t*****返回主菜单请按2*******\n"; in>>y; if(y==2) { ShowMenu(); } else{head=Create(head,cin);} SetOrder(head); //设置排名 return head; } friend const Student * Lookup(const Student *head,int num) //查找指定学号为num结点 { while(head && head->num!=num) head=head->next; return head; } friend void OutputOne(const Student* head) //输出一个学生数据 { cout<<head->Class<<'\t'<<head->name<<'\t'<<head->num<<'\t' <<head->cpp<<'\t'<<head->math<<'\t' <<head->eng<<'\t' <<head->order<<endl; } friend void OutputAll(const Student*head) //输出全部学生数据 { if(!head) {cout<<"\n\n\t\t没有任何学生数据!\n\n"; return;} cout<<"\n\n\t\t学生成绩表\n\n"; cout<<"班级\t姓名\t学号\tC++\t数学\t英语\t名次\n"; while(head) { OutputOne(head);head=head->next; } } friend Student *Modify(Student *head,int num) //修改学号为学生数据 { Student *p1=head,*p2=p1; while(p2&&p2->num!=num) //寻求待修改结点 p1=p2,p2=p2->next; if(p2) //修改指定结点数据 { /*cout<<"\n\n请输入新数据,格式为:\n" <<"班级 姓名 学号 C++ 数学 英语 \n"; cin>>p2->Class>>p2->name>>p2->num>>p2->cpp>>p2->math >>p2->eng;*/ cout<<"班级:"<<endl; cin>>p2->Class; cout<<"姓名:"<<endl; cin>>p2->name; cout<<"学号:"<<endl; cin>>p2->num; cout<<"C++成绩:"<<endl; cin>>p2->cpp; cout<<"数学成绩:"<<endl; cin>>p2->math; cout<<"英语成绩 :"<<endl; cin>>p2->eng; while(!Valid(p2->cpp)||!Valid(p2->math)||!Valid(p2->eng) ) { cout<<"\n\n成绩数据非法!请重新输入,格式为:\n" <<"班级 姓名 学号 C++ 数学 英语 \n"; cin>>p2->Class>>p2->name>>p2->num>>p2->cpp>>p2->math >>p2->eng; } p2->ave=(p2->cpp+p2->math+p2->eng)/3; //将修改指定结点从原链表上修改下来,并重新降序插入原链表 if(p2==p1) head=Insert(p2->next,p2); else { p1->next=p2->next; head=Insert(head,p2); } SetOrder(head); } else cout<<"没找到指定学生!\n"; return head; } friend Student *DeleteStudent(Student *head,int num) { Student *p1=head,*p2=p1; while(p2&&p2->num!=num) p1=p2,p2=p2->next; if(p2) { if(p2==p1) { head=head->next;delete p1; } else { p1->next=p2->next;delete p2; } cout<<"已删除"<<num<<"号学生数据\n"; SetOrder(head); }else cout<<"没找到指定学生!\n"; return head; } friend void Statistic(const Student *head) { int i=0; float ave_cpp=0, ave_math=0, ave_eng=0; while(head) { ave_cpp+=head->cpp; ave_math+=head->math; ave_eng+=head->eng; i++;head=head->next; } if(!i) { cout<<"\n\n没有任何学生数据!\n";return;} cout<<"\n\n\t\t各门课程平均成绩表\n\n"; cout<<"tC++\t数学\t英语\n"; cout<<ave_cpp/i<<'\t'<<ave_math/i<<'\t' <<ave_eng/i<<endl; } friend void DeleteChain(Student *head) {Student *p; while(head) { p=head;head=head->next;delete p; } } friend void ShowMenu(void) { cout<<"\n\n"; cout<<"\t\t******欢迎使用学生成绩管理系统******\n" <<"\t\t* *\n" <<"\t\t* 1.从键盘录入和添加数据 *\n" // <<"\t\t* 2.从文件录入和添加数据 *\n" <<"\t\t* 2.修改数据 *\n" <<"\t\t* 3.查询数据 *\n" <<"\t\t* 4.删除数据 *\n" <<"\t\t* 5.显示数据 *\n" <<"\t\t* 6.平均数据 *\n" // <<"\t\t* 7.保留数据 *\n" <<"\t\t* *\n" <<"\t\t* 0.退出系统 *\n" <<"\t\t**********************************\n\n"; } }; void main (void) { Student *head=0; int select; while(1) { ShowMenu(); cout<<"\t\t请输入你选择(0~6):";cin>>select; switch(select) { case 0: DeleteChain(head); cout<<"\n\n谢谢您使用本系统!\n\n"; return; case 1: head=Create(head,cin); break; /*case 2: { char fname[256]; cout<<"请输入文件名:"; cin.get(); cin.getline(fname,256); ifstream in(fname); if(!in) { cout<<"\n不能打开"<<fname<<"文件!\n";break; } head=Create(head,in); break; }*/ case 2: { int num; cout<<"请输入学号:"; cin>>num; head=Modify(head,num); } break; case 3: { int num; cout<<"请输入学号:"; cin>>num; const Student *t=Lookup(head,num); if(t) { cout<<"\t\t\t\t"<<t->name<<"同学成绩表\n"; cout<<"班级\t姓名\t学号\tC++\t数学\t英语\t名次\n"; OutputOne(t); }else cout<<"没有找到指定学生!\n"; break; } case 4: { int num; cout<<"请输入学号:"; cin>>num; head=DeleteStudent(head,num); }break; case 5: OutputAll(head);break; case 6: Statistic(head);break; /*case 7: if(head) { char fname[256]; cout<<"请输入文件名:"; cin.get(); cin.getline(fname,256); SaveAll(head,fname); }else cout<<"\n\n尚无数据可保留!\n\n"; break;*/ default: cout<<"\n\n非法操作!\n\n"; } } }
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 学术论文 > 其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服