




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、工资信息管理系统一、题目要求设计工资信息管理系统,要求该系统能够实现工资信息管理。系统包括录入、浏览、查询、统计等功能。其中录入功能要求能够添加新的工资信息到文件,浏览功能要求能按照工资卡号、姓名分类浏览,提供分屏显示;有排序功能,排序后按照工资卡号升序或实发工资降序输出;查询功能要求能够按照工资卡号、姓名查询;统计功能要求能够按照月份累计统计某职工在某时间段实发工资总金额。二、 需求分析根据题目要求,由于工资信息是存放在文件中,所以应提供文件的输入输出等操作;在程序中需要浏览工资信息,应提供显示、查找、排序等操作;另外还应提供键盘式选择彩旦实现功能选择。三、 总体设计工资信息管理系统菜单录入
2、追加查询浏览排序四、 详细设计1主函数 void main() menu();/*主函数只用于调用菜单*/ 2.菜单menu()int n,w1;doputs("tt*MENU*nn");puts("tttt 1.enter data");puts("tttt 2.addition data");puts("tttt 3.browse all");puts("tttt 4.search");puts("tttt 5.order");puts("tttt 6.exit
3、");puts("nntt *n");printf("Choice your number(1-6):bb");scanf("%d",&n);if(n<1|n>6)w1=1;getchar();else w1=0;while(w1=1);switch(n)case 1:enter();break;case 2:add();break;case 3:browse();break;case 4:search();break;case 5:order();break;case 6:exit(0);return
4、1;3.各功能模块设计1)录入模块数据结构struct employerint month;char num11;char name20;float yfgz;float sf;float df;float sj;float sfgz;empN;N为职工人数,在此宏定义为100,#define N 100i从0到n-1调用输入函数input(i)输入用户要输入职工记录的个数n那么此阶段的流程图如下i!=0保存save(n)程序enter()int i,n;printf("How many employers(0-%d)?:",N-1);scanf("%d"
5、;,&n);printf("n Enter data nownn");for(i=0;i<n;i+)printf("n input %dth employer record.n",i+1);input(i);if(i!=0) save(n);printf_back();2)追加模块先确定要追加信息的条数,调用n=load()函数,再调用输入函数input(),最后保存追加的记录。整个过的的流程图如下:调用n=load();并计算可以启示录的个数n输入用户要追加学生记录的个数nk=m+ni从n到k调用输入函数input(i)保存追加的记录程序
6、add() int i,n,m,k;FILE *fp;n=load();printf("How many employers are you want to add(0-%d)?:",N-1-n);scanf("%d",&m); k=m+n;for (i=n;i<k;i+) printf("n Input %dth employer record.n",i-n+1);input(i);if(fp=fopen("record.txt","ab")=NULL) printf("
7、;cannot open filen");for(i=n;i<k;i+)if(fwrite(&empi,sizeof(struct employer),1,fp)!=1) printf("file write errorn");fclose(fp);printf_back();3)查询模块下面是流程图:输入查询内容显示找到的记录让用户选择1)查找另一个2)返回菜单返回主菜单提示没有找到是否找到记录询问用户是否继续查找YYN程序search()int i,n,k,w1=1,w2,w3,w4;struct employer e;n=load();dodo
8、k=1;printf("nnEnter name that you want to search! name:");scanf("%s",);printf_face();for(i=0;i<n;i+)if(strcmp(,)=0)k=i;printf_one(k);break;if(k=-1)printf("nnNO exist! please");printf("nnAre you again?nt1).again 2).NO and back bb");scanf
9、("%d",&w1);if(w1=2) break;while(k=-1&&w1=1);w4=0;w3=0;if(k!=-1)printf("nnWhat do you want to do?nt1).Search another 2).Back menu bb");scanf("%d",&w2);if(w3=1|w4=1)save(n);printf("nnSuccessful._.");printf("nnWhat do you want to do?nt1).Sear
10、ch another 2).Back bb");scanf("%d",&w2);while(w2=1);menu();4)浏览模块流程图显示记录按任意键显示下一屏按任意键返回主菜单程序browse() int i,n;n=load();printf_face();for(i=0;i<n;i+)if(i!=0)&&i%10=0)printf("nnPsaa any key to continue .");getch();puts("nn");printf_one(i);printf("t
11、There are %d record.n",n); printf("nPass any key to back .");getch();menu();5)排序模块此阶段按工人工资卡号升序排列程序如下:order()int i,j,n; char t11;n=load();for(i=0;i<n-1;i+)for(j=i+1;j<n;j+)if(strcmp(empi.num,empj.num)>0)strcpy(t,empi.num);strcpy(empi.num,empj.num);strcpy(empj.num,t);save(n);pu
12、ts("nn"); printf_back();4.公共函数1)保存函数程序如下:save(int n)FILE *fp;int i;if(fp=fopen("record.txt","wb")=NULL)printf("nCannot open filen");return NULL;for(i=0;i<n;i+)if(empi.yfgz!=0)if(fwrite(&empi,sizeof(struct employer),1,fp)!=1)printf("file write error
13、n");fclose(fp);return 1;2)加载函数程序如下:load()FILE *fp;int i;if(fp=fopen("record.txt","rb")=NULL)printf("nCannot open filen");return NULL;for(i=0;!feof(fp);i+)fread(&empi,sizeof(struct employer),1,fp);fclose(fp);return(i-1);3)工资信息输入函数程序如下:record_input(int i)int j;pr
14、intf("month:");scanf("%d",&empi.month);no_input(i,i); printf("name:");scanf("%s",&);printf("yfgz:");scanf("%f",&empi.yfgz);printf("sf:");scanf("%f",&empi.sf);printf("df:");scanf("%
15、f",&empi.df);4)输入工资卡号的函数程序如下:no_input(int i,int n)int j,k,w1;dow1=0;printf("NO.:");scanf("%s",empi.num);for(j=0;empi.numj!='0'j+)if(empi.numj<'0'|empi.numj>'9')puts("Input error! Only be made up of (0-9).Please reinput!n");w1=1;bre
16、ak;if(w1!=1)for(k=0;k<n;k+)if(k!=i&&strcmp(empk.num,empi.num)=0)puts("This record is exist.please reinput!n");w1=1;break;while(w1=1);5)计算税金的函数程序如下:sj(int i)if(empi.yfgz<800) empi.sj=0;if(empi.yfgz>800&&empi.yfgz<1400) empi.sj=(empi.yfgz-800)*0.05;if(empi.yfgz>
17、;1400) empi.sj=(empi.yfgz-1400)*0.1;6)计算实发工资的函数程序如下:sfgz(int i)empi.sfgz=empi.yfgz-empi.sf-empi.df-empi.sj;7)显示数据结构项目函数程序如下:void printf_face()printf("ntNO. name month yfgz sf df sj sfgzn");8)显示一个记录的函数程序如下:void printf_one(int i)printf("%s %s %d %f %f %f %f %fn",empi.num,,empi.month,empi.yfgz,empi.sf,empi.df,empi.sj,empi.sfgz);9)一个任务结束时的选择浏览还是返回的函数程序如下:printf_back()int k,w;printf("nntSuccessful._nn");printf("What do you want to do?nnt1)Browse all nowt2).Back: bb");scanf("%d",&w);if(w=1) browse
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025-2030年中国除草剂市场运营状况发展趋势分析报告
- 2025-2030年中国锆英砂行业供需现状及投资发展规划研究报告
- 2025-2030年中国连接器制造市场发展动态及前景趋势预测报告
- 2025-2030年中国轮滑鞋行业发展现状及前景趋势分析报告
- 2025-2030年中国血浆增容剂行业运行动态与发展风险评估报告
- 2025-2030年中国葵花油市场运行态势及发展盈利分析报告
- 2025-2030年中国艺术玻璃行业市场运行态势及投资战略研究报告
- 2025-2030年中国管道检测行业供需现状及投资发展规划研究报告
- 2025-2030年中国空冷器市场运行现状及发展策略分析报告
- 2025-2030年中国种衣剂市场运营状况及发展趋势研究报告
- Unit 3 Environmental Protection Reading and Thinking 选择性必修第三册
- 2025年合伙型公司新合伙人加入协议
- 小学道德与法治课堂教学中提升学生核心素养策略
- 中水回用项目可行性研究报告
- 2025城市商铺买卖合同书
- 基于主题式教学法的初级汉语综合课《我的低碳生活》教学设计
- 微信公众号运营及推广合同
- 2025年浙江长兴文旅集团招聘笔试参考题库含答案解析
- 医院临床科研大数据平台方案
- 2024年北京市中考生物真题卷及答案解析
- 2023年凉山州西昌市人民医院招聘卫生专业技术人员考试真题
评论
0/150
提交评论