学生成绩管理+C++课程设计报告.docx

上传人:b****4 文档编号:11595431 上传时间:2023-03-19 格式:DOCX 页数:25 大小:23.38KB
下载 相关 举报
学生成绩管理+C++课程设计报告.docx_第1页
第1页 / 共25页
学生成绩管理+C++课程设计报告.docx_第2页
第2页 / 共25页
学生成绩管理+C++课程设计报告.docx_第3页
第3页 / 共25页
学生成绩管理+C++课程设计报告.docx_第4页
第4页 / 共25页
学生成绩管理+C++课程设计报告.docx_第5页
第5页 / 共25页
点击查看更多>>
下载资源
资源描述

学生成绩管理+C++课程设计报告.docx

《学生成绩管理+C++课程设计报告.docx》由会员分享,可在线阅读,更多相关《学生成绩管理+C++课程设计报告.docx(25页珍藏版)》请在冰豆网上搜索。

学生成绩管理+C++课程设计报告.docx

学生成绩管理+C++课程设计报告

《高级语言程序设计》

课程设计报告

 

设计题目学生成绩管理

专业计算机科学与技术

班级

姓名

学号

 

2007年6月6日

 

1.设计目标…………………………………………………3

2.设计思想…………………………………………………3

3.类及对象设计……………………………………………4

4.程序源代码………………………………………………5

5.调试记录…………………………………………………30

6.总结………………………………………………………31

学生成绩管理

1.设计目标

(1)题目:

学生成绩管理。

(2)熟练掌握c++语言的基本知识和基本技能

基本掌握面向对象程序设计的基本思路和方法;

利用所学的基本知识和技能,解决简单的面向对象的程序设计及它在实际生活中的应用;

希望自己的程序能有一定的实用意义,使用户可以更快洁方便地查找学生的信息,通过姓名或学号来查找学生的成绩。

(3)增加原始记录

<1>显示各种文件

<2>显示原始记录

<3>保存原始数组

<4>读取原始文件

<5>删除原始文件

<6>建立简明文件

<7>均不及格文件

<8>寻找原始记录

<9>结束程序运行

2.设计思想

由学校通过网络可以管理学生成绩,可以保存学生成绩,可以快速查找学生成绩并且可以增加和删除学生成绩。

将学生的信息:

姓名、学号、各科成绩等存放在一个文件中去该程序可以从该文件中修改记录中的信息,可以添加信息,可以通过不同的方式查找学生的信息(比如说你想查找一名学生的成绩可以输入姓名或学号进行查找),可以随意地删除自己不想要的信息,可以对信息进行按姓名排序以便于自己查找学生信息,可以随时清空自己的通讯录,可以保存记录,可以读取文本中的记录,可以随时新建简表,可以查找两门成绩均不及格的记录等一系列操作。

3.类及对象设计

(1)系统功能模块

根据问题描述和要求,系统要求能够按姓名和学号排序,查找,删除,读取,插入,保存,清空,显示,修改,添加等操作。

确定程序至少应该具备如下功能:

“查询”,“添加”,“删除”,“读取”等以上各种操作。

(2)系统组成

系统有三部分组成:

学生类,链表类(用于对学生进行各种操作的工具),记录本类(用与记录的存盘以及和用户的交互工作)。

学生类包含信息(姓名,学号,数学,C++语言程序设计,电路分析基础,大学英语,VB程序设计,大学物理)和指针。

记录本类又继承了链表类它实现类链表类无法完成的工作与用户的交互而且保存了信息使用户在再次使用这些信息使可以直接在文本利进行操作。

结构体实现了寻找有两门成绩不及格的记录的功能。

结构数组staticstructshorts来实现生成简表;结构数组staticstructbads来生成有两门成绩不及格的记录;学生类classstudent

来生成链和各种函数,增加原始记录,显示各种文件,保存原始数组,读取原始文件,删除原始文件,建立简明文件,均不及格文件,寻找原始记录,结束程序运行。

系统用了级连菜单可以实现多种功能,对相似功能分类。

用户可以随时地选择任何一个选项。

程序不足:

界面太单调,无新意,希望老师给予我更多的宝贵意见。

4.程序源代码

#include

#include

#include

#include

#include

#defineASK(p)do{p=newstudent;if(p==NULL){cout<<"memoryfail!

"<

staticstructshorts

{

charname[16];

doubleave,zf;

}

sm[10]={{"",0}};

staticstructbads

{

charno[10];

charname[16];

doublecpp,math,df,eng,vfp,mz,ave,zf;;

}

bad[10]={{"","",0,0}};

classstudent

{

private:

charno[10];

charname[16];

doublecpp,math,df,eng,vfp,mz,ave,zf;

student*next;

intmenu_select(void);

public:

staticintcount;

student();

~student();

student*input(student*);

voiddisplay(student*);

voidsave(student*);

student*load(student*);

voidhandle_menu(student*);

student*delete_record(student*);

voidshort_record(student*);

student*bad_record(student*top);

voidstudent:

:

find_record(student*);

friendostream&operator<<(ostream&os,student&ob);

friendistream&operator>>(istream&os,student&ob);

};

intstudent:

:

count=0;//声明静态成员记录计数变量

/**************************

*构造函数

**************************/

student:

:

student()

{

next=NULL;

name[0]='0';

no[0]='';

math=0;

cpp=0;

ave=0.0;

}

/**************************

*析构函数

**************************/

student:

:

~student()

{

if(next!

=NULL)

deletenext;

}

voidmain()

{

cout<<"-------------------------------------------------------------\n";

cout<<"\t******************************************\n";

cout<<"\n\t\t你好你进入的是梁秋锋和欧阳的工作区间!

\n\n";

cout<<"\n\t\t欢迎进入,很荣幸您的到来!

\n\n";

cout<<"\n\t\t欢迎您使用学生成绩管理系统!

\n\n";

cout<<"\t******************************************\n";

cout<<"-------------------------------------------------------------\n";

student*top;

ASK(top);

top->handle_menu(top);

}

/**************************

*菜单处理函数

**************************/

voidstudent:

:

handle_menu(student*top)

{

for(;;)

{

switch(menu_select())

{

case1:

top=input(top);

break;

case2:

display(top);

break;

case3:

save(top);

break;

case4:

top=load(top);

break;

case5:

top=delete_record(top);

break;

case6:

short_record(top);

break;

case7:

top=bad_record(top);

break;

case8:

find_record(top);

break;

case9:

cout<<"\n\t您将退出该系统,请多提宝贵意见,谢谢您的使用,再见!

\n"<

deletetop;

return;

}

}

}

/**************************

*菜单选择函数

**************************/

intstudent:

:

menu_select()

{

chars[2];

intcn=0;

cout<<'\n'

<<"\t1.增加原始记录\n"

<<"\t2.显示各种文件\n"

<<"\t3.保存原始文件\n"

<<"\t4.读取原始文件\n"

<<"\t5.删除原始文件\n"

<<"\t6.建立简明文件\n"

<<"\t7.均不及格文件\n"

<<"\t8.寻找原始记录\n"

<<"\t9.结束程序运行\n"

<<"\n\t左边数字对应功能选择,请选1-9;"<

for(;;)

{

gets(s);

cn=atoi(s);//函数原型:

intatoi(constchar*string);函数功能:

把一个字符串转换为integer型;所属文件:

if(cn<1||cn>9)

cout<<"\n\t输入错误,重选1-9:

"<

elsebreak;

}

returncn;

}

/**************************

*文件存储操作函数

**************************/

voidstudent:

:

save(student*top)

{

if(top->name[0]=='0')

{

cout<<"\t没有记录可存!

"<

return;

}

ofstreamout;

out.open("stud.dat",ios:

:

out);

if(!

out)

{

cout<<"\t不能打开文件!

"<

exit

(1);

}

cout<<"\n\t存文件"<

cout<count<<'\n';

student*p=top;

while(p!

=NULL)

{

cout<<*p;

p=p->next;

}

out.close();

cout<count<<"\t条记录已经存入文件,请继续操作。

"<

}

/**************************

*文件读取操作函数

**************************/

student*student:

:

load(student*top)

{

ifstreamin;

in.open("stud.dat",ios:

:

in|ios:

:

nocreate);

if(!

in)

{

cout<<"\t文件不存在!

"<

returntop;

}

cout<<"\n\t取文件..."<

in>>top->count;

in.ignore();

student*p=top;

student*old;

for(inti=0;icount;i++)

{

in>>*p;

ASK(p->next);

old=p;

p=p->next;

in.ignore();

}

old->next=NULL;

in.close();

cout<<"\t取入"<count<<"条记录。

"<

return(top);

}

/**************************

*重载>>运算符函数

**************************/

istream&operator>>(istream&is,student&ob)

{

is.getline(ob.no,10,'\n');//使其能够读如字符串中的空格

is.getline(ob.name,16,'\n');//使其能够读如字符串中的空格

is>>ob.math;

is>>ob.cpp;

is>>ob.df;

is>>ob.eng;

is>>ob.vfp;

is>>ob.mz;

is>>ob.zf;

is>>ob.ave;

returnis;

}

/**************************

*重载<<运算符函数

**************************/

ostream&operator<<(ostream&os,student&ob)

{

os<

os<

os<

os<

os<

os<

os<

os<

os<

os<

returnos;

}

/********************

*输入信息函数

********************/

student*student:

:

input(student*top)

{

ifstreamin;

in.open("sname",ios:

:

in|ios:

:

nocreate);

if(!

in)//判断是否已有文件

{

cout<<"\t还没有建立文件,退出时别忘记存文件。

"<

}

else

{

in.close();

if(top->count==0)

{

cout<<"\t请稍后,取已有文件。

"<

top=load(top);

}

}

student*old,*star;

ASK(star);

old=top;

while(old->next!

=NULL)

{

old=old->next;

}

cout<<"\t输入数据,输入0时结束。

"<

--top->count;

do

{

++top->count;

cout<<"\t学号:

"<

gets(star->no);

if(strcmp(star->no,"0")==0)

break;

cout<<"\t名字:

"<

gets(star->name);

cout<<"\t数学:

"<

cin>>star->math;

cout<<"\tc++语言程序设计:

"<

cin>>star->df;

cout<<"\t电路分析基础:

"<

cin>>star->eng;

cout<<"\t大学英语:

"<

cin>>star->vfp;

cout<<"\tVB程序设计:

"<

cin>>star->vfp;

cout<<"\t大学物理:

"<

cin>>star->mz;

star->zf=star->cpp+star->math+star->df+star->eng+star->vfp+star->mz;

star->ave=(star->zf)/6;

if(top->count==0)top=star;

old->next=star;

old=star;

ASK(star);

}

while

(1);

old->next=NULL;

return(top);

}

/********************

*显示数据信息的函数

********************/

voidstudent:

:

display(student*top)

{

charchoose[2];

intcn=0;

cout<<"\t选择要看的文件类别"<

cout<<"\t1.原文件"<

cout<<"\t2.简明文件"<

cout<<"\t3.均不及格文件"<

cout<<"\t4.输出高于或等于平均成绩的学生名单"<

cout<<"\t请选择1-4"<

gets(choose);

while

(1)

{

cn=atoi(choose);

if(cn<1||cn>4)

{

cout<<"\t输入错误,重选1-4:

"<

gets(choose);

}

elsebreak;

}

switch(cn)

{

case1:

{

if(top->count==0)

{

cout<<"\n\t现在没有记录!

"<

return;

}

student*p=top;

cout<<"\n\t现在共有如下"<

\n";

cout<<"\t学号\t名字\t数学\tc++语言程序设计\t电路分析基础\t大学英语\tVB程序设计\t大学物理\n";

while(p!

=NULL)

{

cout<<'\t'<no<<'\t'<name<<'\t'<math<<'\t'<cpp<<'\t'<df<<'\t'<eng<<'\t'<vfp<<'\t'<mz<<'\t'<zf<<'\t'<ave<<'\n';

p=p->next;

}

cout<

break;

}

case2:

{

ifstreamin;

in.open("stud_mean.dat",ios:

:

in|ios:

:

nocreate);

if(!

in)

{

cout<<"\t文件不存在!

"<

return;

}

cout<<"\n\t取文件。

"<

in.read((char*)sm,sizeofsm);

in.close();

cout<<"\t名字\t平均成绩\n";

for(inti=0;i<10;i++)//,p=p->next)

{

if(sm[i].ave==0)

break;

cout<<'\t'<

}

break;

}

case3:

{

ifstreamin;

in.open("bad.dat",ios:

:

in|ios:

:

nocreate);

if(!

in)

{

cout<<"\t文件不存在!

"<

return;

}

cout<<"\n\t取文件。

"<

in.read((char*)bad,sizeofbad);

in.close();

cout<<"\t学号\t名字\t数学\tc++语言程序设计\t电路分析基础\t大学英语\tVB程序设计\t大学物理\n";

for(inti=0;i<10;i++)

{

if(bad[i].ave==0)break;

cout<<'\t'<

}

break;

}

case4:

{

if(top->count==0)

{

cout<<"\n\t现在没有记录!

"<

return;

}

student*p=top;

cout<<"\n\t现在共有如下"<

\n";

//计算平均成绩

intnum=0;

doublemean=0;

while(p!

=NULL)

{

++num;//记载符合条件的学生人数

mean+=p->ave;//计算平均分之和

p=p->next;

}

mean=mean/num;//计算全部学生的平均分

cout<<"\t平均成绩为:

"<

cout<<"\t其中高于或等于平均成绩的学生信息如下:

\n";

cout<<"\t学号\t名字\t数学\t语文\t平均\n";

p=top;

while(p!

=NULL)

{

if(p->ave>=mean)

{

cout<<'\t'<no<<'\t'<name<<'\t'<math<<'\t'<cpp<<'\t'<ave<<'\n';

}

p=p->next;

}

cout<

break;

}

}

}

/*******************

*生成简明文件函数

*******************/

voidstudent:

:

short_record(student*top)

{

student*p;

p=top;

if(p->count==0)

{

cout<<"\t内存没有可用记录"<

return;

}

for(inti=0;icount;i++,p=p->next)

{

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 解决方案 > 其它

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1