南京邮电大学程序设计-GPA(学分绩点)计算器.doc_第1页
南京邮电大学程序设计-GPA(学分绩点)计算器.doc_第2页
南京邮电大学程序设计-GPA(学分绩点)计算器.doc_第3页
南京邮电大学程序设计-GPA(学分绩点)计算器.doc_第4页
南京邮电大学程序设计-GPA(学分绩点)计算器.doc_第5页
已阅读5页,还剩22页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

程序设计报告 ( 2012 / 2013 学年 第 一 学期) 题目: 学分和绩点计算器学分和绩点计算器 专 业 教育技术学 (网络教育和知识工程) 学 生 姓 名 吴 鹏 班 级 学 号 b11140220 指 导 教 师 李鹏 指 导 单 位 计算机学院 计算机系统与网络教学中心 日 期 2012.12.102012.12.18 评分项评分项优秀优秀良好良好中等中等差差 遵守机房规章制度遵守机房规章制度 上机时的表现上机时的表现 学习态度学习态度 程序准备情况程序准备情况 程序设计能力程序设计能力 团队合作精神团队合作精神 课题功能实现情况课题功能实现情况 算法设计合理性算法设计合理性 用户界面设计用户界面设计 报告书写认真程度报告书写认真程度 内容详实程度内容详实程度 文字表达熟练程度文字表达熟练程度 评评 分分 细细 则则 回答问题准确度回答问题准确度 简简 短短 评评 语语 教师签名:教师签名: 20122012 年年 1212 月月 2525 日日 评分等评分等 级级 备注备注 评分等级有五种:优秀、良好、中等、及格、不及格评分等级有五种:优秀、良好、中等、及格、不及格 - 0 - 学分和绩点计算器学分和绩点计算器 一、一、课题内容和要求课题内容和要求 所选题目 0:学分和绩点计算器 1.课题内容 设计目的: 用 c 或 c+语言开发一个能够自动计算适合于南京邮电大学学生使用的所 获学分和绩点的计算器。并且该绩点计算器能够保证良好的扩展性能。 (1)基本掌握面向过程程序设计的基本思路和方法; (2)达到熟练掌握 c 语言的基本知识和技能; (3)能够利用所学的基本知识和技能,解决简单的程序设计问题 程序功能: (1)学生基本信息及成绩所选科目成绩的录入。 (2)基本信息的查询与修改。 (二)课题要求 1. 基本要求。 (1) 输入课程名、学分和成绩,通过绩点计算公式计算相应的绩点,满足 如下要求: 根据南京邮电大学的本科生南京邮电大学学生学籍管理办法规定:为 反映学生学习的质量,采用学分绩点制的学习质量评定方法。学生学分绩点以 平均学分绩点(gpa) 表示,其计算方法如下: (课程名,学分,成绩,等级,绩点) 低于 60 分折合为 0 绩点,不及格折合为 0 绩点 6069 分折合为 1.01.9 绩点,及格折合为 1.5 绩点; 7079 分折合为 2.02.9 绩点,中等折合为 2.5 绩点; 8089 分折合为 3.03.9 绩点,良好折合为 3.5 绩点; 90100 分折合为 4.05.0 绩点,优秀折合为 4.5 绩点。 - 1 -1 (课程学分数绩点数 k(课程数)) 平均学分绩点(gpa) = 课程学分数 平均学分绩点分为学年平均学分绩点和累积平均学分绩点:即按学年结算 的平均学分绩点称为学年平均学分绩点;从入学后累积结算的平均学分绩点积 为累积平均学分绩点。 (2) 判断所获得的绩点是否合格,能给出相应的结果提示; (3) 程序操作友好、界面美观。 2. 扩展要求。 (1) 从文件中读取课程的学分与成绩,并保存绩点计算的结果;并根据排 序算法排序,给出每门课程所获得的绩点。 (2) 实现绩点的预警功能。如按照班级(或者专业)的学分统计查询功能, 从文件读入多个学生的学分绩点,按照总的绩点排序。 二、需求分析二、需求分析 管理系统工作原理图(简图): 南京邮电大学学生 gpa 管理系统 学生信息及成绩录入 查找插入删除修改保存备份排序 制 表 打 印 - 2 -2 (1)界面美观的友好操作系统:简洁、明了、直观的友好操作系统,将文件中 已经写好的菜单打印在显示屏幕上,指导操作者进行下一步操作。同时根据操 作者的选择,进行相关信息的调用或存储。 (2)信息的载入与修改:以文本形式打开,并修改相关信息。在事先文本不存 在的情况下,提示用户文本不存在,并重新创建一个新的文本文档 student.doc。 (3)查找:根据用户对菜单项的选择,调用已经存储的用户信息,按照选项指 令(学号,姓名,绩点)进行相关大类或更为详细的查找,调用所需学生信息 进行查看或进一步编辑。 (4)插入:创建新的学生信息,并写入已经存在的文本中。同时建立新的链表 结点,方便以后对该创建信息的管理。 (5)删除:调用已经存在的文本中的信息后,若该信息不再需要,用户希望删 除该信息,则用户可以下达指令,通过链表对该信息进行删除。 (6)修改:调用已经存在的文本中的信息后,若该信息有新的变动,用户希望 修改该信息,则用户可以下达指令,通过链表对该信息进行修改。 (7)保存:所有信息在用户进行编辑以后,将自动以文本形式进行保存,以免 数据的丢失造成不必要的损失。 (8)备份:通过文件格式读写函数,将源文件信息写到客户提供的目标文件中。 (9)排序:根据需要,在用后输入学生信息后,系统将通过冒泡排序法自动按 照绩点的高低对所有信息进行排序。 (10)制表打印:所有信息采编完毕后,当客户通过菜单选项在屏幕上输出所 有信息时,程序将自动进行排版,并以表格的形式在屏幕上输出,方便客户的 阅览。 三、概要设计三、概要设计 主要结构体: (1)学生信息结构 struct student/定义学生信息结构 long num;/学生学号 - 3 -3 char name20;/学生名字 char sex10;/学生性别 float gpa;/学生绩点 ; typedef struct student type;/将学生信息结构重新定义为 type (2)学生绩点计算结构 省略 省略 sum_score+=score;/计算总成绩 sum_gpa+=score*level;/计算总绩点 gpa=sum_gpa/sum_score;/计算平均绩点 (3)系统的操作函数 1、输入函数:其中包括学生的姓名、学号以及学生的考试科目、成绩、绩点等 相关信息;可用 gpa 计算器源程序代码来实现此操作。 2、查询函数:可用struct node *searchmanage(struct node *head) 来实现。找到 就输出此学生全部信息包括学生的学号、姓名、性别以及 gpa。 3、编辑函数:可用 insert( )函数来实现。其中通过学号的大小来比较的, 并且以此来排序。 4、输出函数:gpa=sum_gpa/sum_score 函数进行学生 gpa 的计算 ,head=readfile(head)调用学生个人信息及 gpa 信息 5、退出函数:可用一个函数 exit()来实现,首先将信息保存到文件中,释 放动态创建的内存空间,再退出此程序 (4)输入与写入文件 1、函数原型:scanf(“%d”, float sum_gpa=0.0,gpa=0.0,level=0.0,sum_score=0.0,score=1.0; int grade=0,n=0,i=0,k; char a20,d; char wupeng; char name20; char id20; printf(“*n“); printf(“* 欢 迎 您 使 用 *n“); printf(“* *n“); printf(“* 南京邮电大学学生 gpa 管理系统 *n“); printf(“* *n“); printf(“* 本系统由 b11140220 吴 鹏 制作 *n“); printf(“*n“); printf(“输入科目数:n“); scanf( “%d“, getchar();/这个 getchar 把前一个 输入的回车滤掉。不明白可以删掉试一试 printf( “添加一个学生?y/n “ ); wupeng= getchar(); while( wupeng != n scanf(“%s“, printf(“请输入学生学号:n“); scanf(“%s“, if(n0) - 5 -5 for(i=0;i;若学科为等级制,则按n“); scanf(“%s“, if(d=f) printf(“请输入%s 学科学分(1-6):n“,a); scanf(“%f“, if(score=0 scanf(“%d“, if(k=1) - 6 -6 printf(“%s 成绩为优秀,绩点为 4.5n“,a); level=4.5; if(k=2) printf(“%s 成绩为良好,绩点为 3.5n“,a); level=3.5; if(k=3) printf(“%s 成绩为中等,绩点为 2.5n“,a); level=2.5; if(k=4) printf(“%s 成绩为及格,绩点为 1.5n“,a); level=1.5; if(k=5) printf(“%s 成绩为不及格,绩点为 0n“,a); level=0; else getchar(); printf(“errorn“); i=i-1; continue; sum_score+=score; sum_gpa+=score*level; gpa=sum_gpa/sum_score; printf(“您的平均 gpa 分数为%.2f:n“,gpa); printf(“n“); printf(“*您的结果 *n“); printf(“n“); printf(“姓名: %sn“,name); printf(“学号: %sn“,id); - 7 -7 printf(“平均 gpa:%.2f:n“,gpa); if(gpa void printnode(type data) - 8 -8 printf(“%8ld“,data.num); printf(“%8s“,); printf(“%8s“,data.sex); printf(“%10.2f“,data.gpa); printf(“n“); void readnode(type *pdata) printf(“输入一个学生的信息n“); printf(“学号:n“); scanf(“%ld“, printf(“姓名:n“); scanf(“%s“,pdata-name); printf(“性别:n“); scanf(“%s“,pdata-sex); printf(“请输入该学生的绩点:n“); scanf(“%f“, int endwith(type data) return data.num=0; int equal(type data1,type data2,int condition) if(condition=1) return data1.num=data2.num; else if(condition=2) if(strcmp(,)=0) return 1; else return 0; else if(condition=3) return data1.rank=data2.rank; else return 1; int larger(type data1,type data2,int condition) if(condition=1) return data1.numdata2.num; - 9 -9 if(condition=2) return data1.totaldata2.total; return 1; #endif /*file.h*/*file.h*/ #include #include #include“list.h“ void createfile() type data; file *fp; if(fp=fopen(“d:student.dat“,“wb“)=null) printf(“打开学生信息失败!n“); exit(0); printf(“读取学生信息直到学号为 0 结束n“); readnode( while(!endwith(data) fwrite( readnode( fclose(fp); struct node *readfile(struct node *head) type data; file *fp; head=null; if(fp=fopen(“d:student.dat“,“rb“)=null) printf(“文件打开失败,请先创建文件!n“); return(0); fread( while(!feof(fp) head=insertorder(head,data,1); fread( - 10 -10 fclose(fp); return head; void savefile(struct node*head) struct node *p=head; file *fp; if(fp=fopen(“d:student.dat“,“wb“)=null) printf(“打开失败!n“); exit(0); if(head=null) printf(“n 无记录!n“); return; while(p) fwrite( p=p-next; fclose(fp); /*list.h*/*list.h*/ /链表操作的完整程序 #ifndef _list #define _list #include“prepare.h“ /文本包含,对节点数据域为 type 类型 struct node *createbackward();/后插法新建链表 struct node *createforward();/前插法新建列表 struct node *createinsert();/按序插入法新建列表 struct node *printlist(struct node *head);/列表的遍历 struct node *searchnode(struct node *head,type data,int condition);/单链 表的查找 struct node *insertafter(struct node *head,type data);/尾部插入 struct node *insertorder(struct node *head,type data,int condition);/ 有序插入 struct node *delete(struct node *head,type data);/删除节点 - 11 -11 struct node *reverse(struct node *head);/单链表逆置 struct node *printlist(struct node *head) struct node *p; if(head=null) printf(“n 无信息!n“); return null; for(p=head;p;p=p-next)/p 从头指针开始,每循环一次后移动 1 节点 printnode(p-data);/p 非空时执行循环体,调用 printnode 函数 printf(“n“);/节点的元素值,最后换行 return head; struct node *creatbackward()/后插法新建列表 struct node *head,*p,*tail;/tail 定位当前列表最后一个节点位置 type data; head=null;tail=null;/链表未建立时对头指针和尾指针进行清零处理 printf(“input data end with 0:“); readnode(/调用 readnode 输入一个节点的数域的值 while(!endwith(data)/endwith(data)函数值为真时结束链表节点的生 成 p=(struct node *)malloc(size);/利用指针 p 申请新节点的动态空间 p-data=data;/数据域赋值 p-next=null;/新节点的指针域赋值 if(head=null)/初始链为空,需要修改头指针 head=p; else/链非空时,将 p 置于 tail 所指节点之后 tail-next=p; tail=p;/使 tail 指向新的链尾,便于下次插入 readnode( return head; struct node *creatforward()/前插法新建列表 struct node *head,*p; type data; head=null;/链表未建立时对头指针进行清零处理 - 12 -12 printf(“input data end with 0:n“); readnode(/调用 readnode 输入一个节点的数据域的值 while(!endwith(data)/endwith(data)函数值为真时结束链表节 点的生成 p=(struct node *)malloc(size);/利用指针 p 申请新节点的动态空间 p-data=data;/ p-next=head; head=p; readnode( return head; struct node *searchnode(struct node *head,type data,int condition) struct node *p=head; if(head=null) printf(“n 无记录!n“); return 0; while(p if(p) return p; return 0; struct node *insertafter(struct node *head,type data) struct node *p,*p1; p=(struct node *)malloc(size); p-data=data; p-next=null; if(head=null) head=p; return head; p1=head; while(p1-next) - 13 -13 p1=p1-next; p1-next=p; return head; struct node *insertorder(struct node *head,type data,int condition) struct node *p,*p1,*p2; p2=head; p=(struct node *)malloc(size); p-data=data; p-next=null; if(head=null) head=p; return head; while(p2 p2=p2-next; if(head=p2) head=p; else p1-next=p; p-next=p2; return head; struct node *createinsert() struct node *head; type data; head=null; printf(“input data end with 0:n“); readnode( while(!endwith(data) head=insertorder(head,data,1); readnode( return head; - 14 -14 struct node *delete(struct node *head,type data) struct node *p=head,*q=null; if(head=null) printf(“n 无记录!n“); return head; while(p p=p-next; if(p) if(q) q-next=p-next; else head=head-next; free(p); else printf(“无此信息!n“); return head; struct node *reverse(struct node *head) struct node *p=head,*q; head=null; while(p) q=p-next; p-next=head; head=p; p=q; return head; #endif - 15 -15 /*wupeng.c*/*wupeng.c*/ /主程序 #include #include #include“file.h“ void printhead() /打印表头函数 printf(“%8s%10s%8s%8.2f n“,“学号“,“姓名“,“性别“,“绩点n“); void menu() /一级菜单函数 printf(“*n“); printf(“* 欢 迎 您 使 用 *n“); printf(“* *n“); printf(“* 南京邮电大学学生 gpa 管理系统 *n“); printf(“* *n“); printf(“* 本系统由 b11140220 吴 鹏 制作 *n“); printf(“*n“); printf(“ *1.显示基本信息*n“); printf(“ *2.基本信息管理*n“); printf(“ *3.考试成绩统计*n“); printf(“ *0.退 出*n“); void menubase() /基本信息管理的二级菜单 printf(“ *1.插入学生记录*n“); printf(“ *2.删除学生记录*n“); printf(“ *3.修改学生记录*n“); printf(“ *0.返回上层菜单*n“); void menusearch() /根据条件查询的二级菜单 printf(“ *1.按学号查询*n“); printf(“ *2.按姓名查询*n“); printf(“ *0.返回上层菜单*n“); struct node *basemanage(struct node *head) /基本信息管理模块的实现 int choice; type data; - 16 -16 struct node *p; do /实现多次选择二级菜单 menubase(); /调用二级菜单显示函数 printf(“请选择你想进行的操作:n“); scanf(“%d“, switch(choice) case 1: readnode( /读入待插入学生记录 head=insertorder(head,data,1); break; case 2: printf(“请输入需要删除的学号:n“); scanf(“%d“, /读入学号后进行删除 head=delete(head,data); break; case 3: readnode( p=searchnode(head,data,1); /查找是否存在 if(p)p-data=data; /存在则修改 elseprintf(“此人不存在!n“); break; case 0: break; while(choice); /回到二级菜单 return head; struct node *searchmanage(struct node *head) /条件查询模块的实现 int choice; type data; struct node *p; do menusearch(); printf(“请选择您想进行的操作:n“); scanf(“%d“, switch(choice) case 1: printf(“根据学号查询:n“); scanf(“%ld“, break; case 2: printf(“根据姓名查询:n“); - 17 -17 scanf(“%s“, break; case 0: break; if(choice=1 /输出记录 else printf(“该查询不存在!n“); while(choice); return head; struct node *runmain(struct node *head,int choice) /根据选项受 main 函数调用 switch(choice) case 1: printhead(); head=printlist(head); /调用显示基本信息 break; case 2: head=basemanage(head); /调用基本信息管理 break; case 3: head=searchmanage(head); /调用根据条件查询 break; case 0: break; return head; int main() struct node *head=null;

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论