当前位置:首页 > C++学生成绩管理系统课程设计报告
一.目的与要求
通过本课程设计的实践,全面总结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);
1
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\ //<<\班级 姓名 学号 C++ 数学 英语 \\n\ //in>>Class>>name>>num>>cpp>>math>>eng; //cout<<\请输入学生数据:\\n\ cout<<\班级:\ in>>Class;
cout<<\姓名:\ in>>name; cout<<\学号:\ in>>num; cout<<\的成绩:\ in>>cpp; cout<<\数学的成绩:\ in>>math; cout<<\英语的成绩 :\ 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<<\继续添加请按1*******\\n\ cout<<\返回主菜单请按2*******\\n\
2
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< 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) //查3
共分享92篇相关文档