南京邮电大学程序设计GPA(学分绩点)计算器.doc

上传人:土8路 文档编号:10513347 上传时间:2021-05-20 格式:DOC 页数:27 大小:379.50KB
返回 下载 相关 举报
南京邮电大学程序设计GPA(学分绩点)计算器.doc_第1页
第1页 / 共27页
南京邮电大学程序设计GPA(学分绩点)计算器.doc_第2页
第2页 / 共27页
南京邮电大学程序设计GPA(学分绩点)计算器.doc_第3页
第3页 / 共27页
南京邮电大学程序设计GPA(学分绩点)计算器.doc_第4页
第4页 / 共27页
南京邮电大学程序设计GPA(学分绩点)计算器.doc_第5页
第5页 / 共27页
点击查看更多>>
资源描述

《南京邮电大学程序设计GPA(学分绩点)计算器.doc》由会员分享,可在线阅读,更多相关《南京邮电大学程序设计GPA(学分绩点)计算器.doc(27页珍藏版)》请在三一文库上搜索。

1、程序设计报告 ( 2012 / 2013 学年 第 一 学期) 题目: 学分和绩点计算器学分和绩点计算器 专 业 教育技术学 (网络教育和知识工程) 学 生 姓 名 吴 鹏 班 级 学 号 B11140220 指 导 教 师 李鹏 指 导 单 位 计算机学院 计算机系统与网络教学中心 日 期 2012.12.102012.12.18 评分项评分项优秀优秀良好良好中等中等差差 遵守机房规章制度遵守机房规章制度 上机时的表现上机时的表现 学习态度学习态度 程序准备情况程序准备情况 程序设计能力程序设计能力 团队合作精神团队合作精神 课题功能实现情况课题功能实现情况 算法设计合理性算法设计合理性 用

2、户界面设计用户界面设计 报告书写认真程度报告书写认真程度 内容详实程度内容详实程度 文字表达熟练程度文字表达熟练程度 评评 分分 细细 则则 回答问题准确度回答问题准确度 简简 短短 评评 语语 教师签名:教师签名: 20122012 年年 1212 月月 2525 日日 评分等评分等 级级 备注备注 评分等级有五种:优秀、良好、中等、及格、不及格评分等级有五种:优秀、良好、中等、及格、不及格 学分和绩点计算器学分和绩点计算器 一、一、课题内容和要求课题内容和要求 所选题目 0:学分和绩点计算器 1.课题内容 设计目的: 用 C 或 C+语言开发一个能够自动计算适合于南京邮电大学学生使用的所

3、获学分和绩点的计算器。并且该绩点计算器能够保证良好的扩展性能。 (1)基本掌握面向过程程序设计的基本思路和方法; (2)达到熟练掌握 C 语言的基本知识和技能; (3)能够利用所学的基本知识和技能,解决简单的程序设计问题 程序功能: (1)学生基本信息及成绩所选科目成绩的录入。 (2)基本信息的查询与修改。 (二)课题要求 1. 基本要求。 (1) 输入课程名、学分和成绩,通过绩点计算公式计算相应的绩点,满足 如下要求: 根据南京邮电大学的本科生南京邮电大学学生学籍管理办法规定:为 反映学生学习的质量,采用学分绩点制的学习质量评定方法。学生学分绩点以 平均学分绩点(GPA) 表示,其计算方法如

4、下: (课程名,学分,成绩,等级,绩点) 低于 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 绩点。 (课程学分数绩点数 K(课程数)) 平均学分绩点(GPA) = 课程学分数 平均学分绩点分为学年平均学分绩点和累积平均学分绩点:即按学年结算 的平均学分绩点称为学年平均学分绩点;从入学后累积结算的平均学分绩点积 为累积平均学分绩

5、点。 (2) 判断所获得的绩点是否合格,能给出相应的结果提示; (3) 程序操作友好、界面美观。 2. 扩展要求。 (1) 从文件中读取课程的学分与成绩,并保存绩点计算的结果;并根据排 序算法排序,给出每门课程所获得的绩点。 (2) 实现绩点的预警功能。如按照班级(或者专业)的学分统计查询功能, 从文件读入多个学生的学分绩点,按照总的绩点排序。 二、需求分析二、需求分析 管理系统工作原理图(简图): 南京邮电大学学生 GPA 管理系统 学生信息及成绩录入 查找插入删除修改保存备份排序 制 表 打 印 (1)界面美观的友好操作系统:简洁、明了、直观的友好操作系统,将文件中 已经写好的菜单打印在显

6、示屏幕上,指导操作者进行下一步操作。同时根据操 作者的选择,进行相关信息的调用或存储。 (2)信息的载入与修改:以文本形式打开,并修改相关信息。在事先文本不存 在的情况下,提示用户文本不存在,并重新创建一个新的文本文档 student.doc。 (3)查找:根据用户对菜单项的选择,调用已经存储的用户信息,按照选项指 令(学号,姓名,绩点)进行相关大类或更为详细的查找,调用所需学生信息 进行查看或进一步编辑。 (4)插入:创建新的学生信息,并写入已经存在的文本中。同时建立新的链表 结点,方便以后对该创建信息的管理。 (5)删除:调用已经存在的文本中的信息后,若该信息不再需要,用户希望删 除该信息

7、,则用户可以下达指令,通过链表对该信息进行删除。 (6)修改:调用已经存在的文本中的信息后,若该信息有新的变动,用户希望 修改该信息,则用户可以下达指令,通过链表对该信息进行修改。 (7)保存:所有信息在用户进行编辑以后,将自动以文本形式进行保存,以免 数据的丢失造成不必要的损失。 (8)备份:通过文件格式读写函数,将源文件信息写到客户提供的目标文件中。 (9)排序:根据需要,在用后输入学生信息后,系统将通过冒泡排序法自动按 照绩点的高低对所有信息进行排序。 (10)制表打印:所有信息采编完毕后,当客户通过菜单选项在屏幕上输出所 有信息时,程序将自动进行排版,并以表格的形式在屏幕上输出,方便客

8、户的 阅览。 三、概要设计三、概要设计 主要结构体: (1)学生信息结构 struct Student/定义学生信息结构 long num;/学生学号 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、输入函数:其中包括学生

9、的姓名、学号以及学生的考试科目、成绩、绩点等 相关信息;可用 GPA 计算器源程序代码来实现此操作。 2、查询函数:可用struct node *searchManage(struct node *head) 来实现。找到 就输出此学生全部信息包括学生的学号、姓名、性别以及 GPA。 3、编辑函数:可用 insert( )函数来实现。其中通过学号的大小来比较的, 并且以此来排序。 4、输出函数:GPA=sum_GPA/sum_score 函数进行学生 GPA 的计算 ,head=readFile(head)调用学生个人信息及 GPA 信息 5、退出函数:可用一个函数 exit()来实现,首先将

10、信息保存到文件中,释 放动态创建的内存空间,再退出此程序 (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(* 本系统

11、由 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) for(i=0;in;i+) printf(请输入第%d 课课程名:n,i+1); scanf(%s,a); printf(若学科为分数制,请按;若学科为等级制,则按n

12、); scanf(%s, if(d=F) printf(请输入%s 学科学分(1-6):n,a); scanf(%f, if(score=0 level=0; else printf(score 输入错误!n); else if(d=D) printf(请输入%s 学科学分(1-6):n,a); scanf(%f, printf(若为优秀,则按,若为良好,则按,若为中 等,则按,若为及格,则按, 若为不 及格,则按n); scanf(%d, if(k=1) printf(%s 成绩为优秀,绩点为 4.5n,a); level=4.5; if(k=2) printf(%s 成绩为良好,绩点为 3

13、.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,GP

14、A); printf(n); printf(*您的结果 *n); printf(n); printf(姓名: %sn,name); printf(学号: %sn,ID); printf(平均 GPA:%.2f:n,GPA); if(GPA1.8) printf(您的成绩低于南京邮电大学合格绩点,请注意 1n); else printf(您的成绩已达南京邮电大学合格绩点,请继续保持!n); printf( 添加一个学生?Y/N ); getchar(); Wupeng = getchar(); GPA 管理系统源程序代码 /*node.h*/*node.h*/ #ifndef _NODE #de

15、fine _NODE struct Student long num; char name20; char sex10; float GPA; int total; int rank; ; typedef struct Student Type; const int sizeStu=sizeof(Type); struct node Type data; struct node*next; ; const int size=sizeof(struct node); #endif /*prepare.h*/*prepare.h*/ #ifndef _PREP #define _PREP #inc

16、ludenode.h #include void printNode(Type data) printf(%8ld,data.num); printf(%8s,data.name); 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(

17、请输入该学生的绩点: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(data1.name,data2.name)=0) return 1; else return 0; else if(condition=3) return data1.rank=data2.rank; else retur

18、n 1; int larger(Type data1,Type data2,int condition) if(condition=1) return data1.numdata2.num; if(condition=2) return data1.totaldata2.total; return 1; #endif /*file.h*/*file.h*/ #include #include #includelist.h void createFile() Type data; FILE *fp; if(fp=fopen(D:student.dat,wb)=NULL) printf(打开学生信

19、息失败!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,

20、1); fread( 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 #in

21、cludeprepare.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 *InsertAft

22、er(struct node *head,Type data);/尾部插入 struct node *InsertOrder(struct node *head,Type data,int condition);/ 有序插入 struct node *Delete(struct node *head,Type data);/删除节点 struct node *Reverse(struct node *head);/单链表逆置 struct node *printList(struct node *head) struct node *p; if(head=NULL) printf(n 无信息!

23、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

24、 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 指向新的链尾,便于下次插入 re

25、adNode( return head; struct node *CreatForward()/前插法新建列表 struct node *head,*p; Type data; head=NULL;/链表未建立时对头指针进行清零处理 printf(Input data end with 0:n); readNode(/调用 readNode 输入一个节点的数据域的值 while(!endWith(data)/endWith(data)函数值为真时结束链表节 点的生成 p=(struct node *)malloc(size);/利用指针 p 申请新节点的动态空间 p-data=data;/

26、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 *)ma

27、lloc(size); p-data=data; p-next=NULL; if(head=NULL) head=p; return head; p1=head; while(p1-next) 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=N

28、ULL) 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; struct

29、 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;

30、while(p) q=p-next; p-next=head; head=p; p=q; return head; #endif /*wupeng.c*/*wupeng.c*/ /主程序 #include #include #includefile.h void printHead() /打印表头函数 printf(%8s%10s%8s%8.2f n,学号,姓名,性别,绩点n); void menu() /一级菜单函数 printf(*n); printf(* 欢 迎 您 使 用 *n); printf(* *n); printf(* 南京邮电大学学生 GPA 管理系统 *n); printf

31、(* *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.

32、按学号查询*n); printf( *2.按姓名查询*n); printf( *0.返回上层菜单*n); struct node *baseManage(struct node *head) /基本信息管理模块的实现 int choice; Type data; struct node *p; do /实现多次选择二级菜单 menuBase(); /调用二级菜单显示函数 printf(请选择你想进行的操作:n); scanf(%d, switch(choice) case 1: readNode( /读入待插入学生记录 head=InsertOrder(head,data,1); break;

33、 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

34、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); scanf(%s, break; case 0: break; if(choice=1 /输出记录 else printf(该查询不存在!n); while(choice); return head; struct node *runMain(struct no

35、de *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; /定义头指针 int choice;/输入一级菜单

36、head=readFile(head);/执行文件打开 if(!head) createFile();/创建 head=readFile(head);/读入链表 do menu(); printf(请输入你的选择:n); scanf(%d, if(choice=0 完成。 5、基本计算程序与管理程序嵌套不成功,后采用两套不同的程序解决此问题。 七、程序设计总结七、程序设计总结 由于本课题中的许多知识点都没有学过都要靠自己到课外的资料中去查找。 在用的时候难免出现这样那样的错误。如开始设计出来的菜单不是预想的那样, 而是总个窗中出现混乱。解决的这个问题的办法是调整。一个系统的菜单和提 示信息非常

37、重要。如果没有这些用户根本不知道怎么用你设计的这个系统。在 设计的调试过程中也无法顺利的完成调试工作。有了一个清晰简单的菜单和一 些提示信息这后,调试过程完成的非常顺利。 回顾起此次课程设计,我感慨颇 多,的确,从拿到题目到完成整个编程,从理论到实践,在整整两个礼拜的日 子里,可以学到很多很多的东西,同时不仅可以巩固了以前所学过的知识,而 且学到了很多在书本上所没有学到过的知识。通过这次课程设计使我们懂得了 理论与实际相结合是很重要的,只有理论知识是远远不够的,只有把所学的理 论知识与实践相结合起来,从理论中得出结论,才能真正为社会服务,从而提 高自己的实际动手能力和独立思考的能力。在设计的过

38、程中遇到问题,可以说 得是困难重重,这毕竟第一次做的,难免会遇到过各种各样的问题,同时在设 计的过程中发现了自己的不足之处,对以前所学过的知识理解得不够深刻,掌 握得不够牢固,比如说结构体通过这次课程设计之后,一定把以前所学过 的知识熟悉了,本次课程设计结束了,我们通过这次实践学到了许多知识。学 到了设计一个简单的系统。要注意哪些方面。也使我们知道自己哪些方面做得 还不够。这不仅是程序设计,更是锻炼我们处理问题的能力,同时也使我们了解 到团队合作的可贵.编写程序是件细心活,稍不留神就会出错,这就必须要求我们 对待事情要认真!在编写程序的过程中,错误不断出现,不同的类型(如少写了一 个符号,写错了字母,用错了函数等等)层出不穷,这考验我们待事细心,耐心,能 不能坚持到底,不能半途而废。 但我们总结出了一点点的经验如下: 1、要对系统的功能和要求做出详细的分析,并合理分解任务。 2、把分解出来的子任务,做给一个相对独立的模块。 3、在设计一个模块之前,要简单构想一下总界面的显视情况。 针对构想出来的界面进行程序的编写。

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

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1