


下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、一、需求分析 1二、概要设计 3三、详细设计 12四、调试分析 12五、用户手册 13六、测试数据 17七、附录 31一、需求分析(1)源文件采用多文件的工程结构。(2)数据存储采用文件形式。(3)标准C+俞入输出( 4)程序完成企业人事工资管理,能够实现工资的录入、统计(整个单位的平 均工资、最高工资、最低工资和工资均方差;各部门的平均工资、最高工资、 最低工资和工资均方差) 、查询(按工号或姓名查询) 、修改、删除等功能( 5)程序执行的命令:( 1)录入员工工资信息;( 2 )选择需要执行的操作(添加、统计、删除、修改、查询) ;( 3)输出结果。一、 概要设计1. 设计类的数据类型定义
2、class messageprivate:char bornplace10,duty10;/ 籍贯 职务int ID;/ 身份证号public:char name10,bume n10;/姓名 部门int number; /工号int basesalary;/基本工资int jobsalary;/ 岗位工资int yljj;/ 医疗基金int sj;/ 税金int jia ngji n; 奖金friend void modify(int x);/友员函数friend int del(int x); /友员函数2. 程序模块( 1 )录入操作: void writen(int x) ,该模版主要
3、实现工资信息的录入;(2) 添加操作:void add(int x),该模版主要实现工资信息的添加;( 3)删除操作: void del(int x) ,该模版主要实现工资信息的删除;(4) 修改操作:void modify (int x),该模版主要实现工资信息的修改;( 5)查询操作: void find(int x) ,该模版主要实现工资信息的查询(按名字查 询或按工号查询) ;(6)统计操作:void count(int x),该模版主要实现工资信息的统计(统计单位 的平均工资、最高工资、最低工资、工资均方差;统计部门的平均工资、 最高工资、最低工资、工资均方差) 。3程序模块结构vo
4、id main()菜单(输入选择) ;操作;三、详细设计( 1 )类模块class messageprivate:char bornplace10,duty10;/ 籍贯 职务int ID;/ 身份证号public:char name10,bumen10;/ 姓名 部门int number; / 工号int basesalary;/ 基本工资int jobsalary;/ 岗位工资int yljj;/ 医疗基金int sj;/ 税金int jiangjin;/ 奖金message()/*构造函数void xinxi(char a_name,char a_bornplace,char a_dut
5、y,char a_number,int a_basesalary,int a_jobsalary,int a_jiangjin,int a_yljj,int a_sj)strcpy(name,a_name); strcpy(bornplace,a_bornplace); strcpy(duty,a_duty); strcpy(bumen,a_bumen);ID=a_ID;number=a_number; basesalary=a_basesalary; jobsalary=a_jobsalary;jiangjin=a_jiangjin;yljj=a_yljj;sj=a_sj;message &
6、amp;operator=(const message &s) /* strcpy(name,);strcpy(bornplace,s.bornplace);strcpy(duty,s.duty); strcpy(bumen,s.bumen);ID=s.ID;number=s.number;basesalary=s.basesalary;jobsalary=alary;jiangjin=s.jiangjin;yljj=s.yljj;sj=s.sj;return * this;friend void modify(int x);/*friend int del(i
7、nt x);void put()a_bumen,int a_ID,int运算符重载友元函数cout< <n ame<<""<<bor nplace<<" "<<duty<<" "<<bume n<<""<<ID<<""<<n umber<<" "<<basesalary<<" "<&l
8、t;jobsalary<<" "<<jia ngji n<<" "<<yljj<<" "<<sj<<e ndl;message()*y|析(2) 主函数流程图(3) 录入、添加函数流程图(4) 删除函数流程图message a30;fstream ap("wenjian.txt",ios:in|ios:out); 文件打开操作cout<<"请输入要删除人员信息的名字:";cin>>ming
9、;/输入要删除的人员姓名cout<<endl;for(j=0,i=0;i<temp;i+) / 判断是否删除if(strcmp(,ming)=0) / 标记要删除的信息 flag=i;if(flag=-1)cout<<" 没有要删除的信息。 "<<endl;return 0;for(j=0,i=0;i<temp,j<temp-1; ) / 删除信息if(flag!=i)aj=bi; / 删除信息i+;j+;elsei+;(5) 修改函数流程图startint i,j,char n ame输入ming1r输入
10、修改的信息(名字,工号,职务,身份证号,籍贯,没找到要修改 的Tcin(n ame ,nu m,duty,ID,bor nplace,basesalary,jobsalary,jia ngji n,yljj,sj)11Fendcout<<"输入要修改人的名字:";cin»ming;cout<<e ndl;cout<<flag<<e ndl;cout<<"请输入修改信息:"<<endl;cout<<"姓名:"<<endl;cin&g
11、t; >bflag. name;cout<<"籍贯:"<<endl;cin> >bflag.bor nplace;cout<<"职务:"<<endl;cin> >bflag.duty;cout<<"部门:"<<endl;cin> >bflag.bume n;cout<<"身份证号:"<<endl;cin >>bflag.ID;cout<<"工号:
12、"<<endl;cin> >bflag. nu mber;cout<<"基本工资:"<<endl;cin> >bflag.basesalary;cout<<"岗位工资:"<<endl;cin> >alary;cout<<"奖金:"<<endl;cin> >bflag.jia ngji n;cout<<"医疗住房基金:"<<endl;
13、cin> >bflag.yljj; cout<<"税金:"<<endl; cin> >bflag.sj; cout<<e ndl;(6) 查找函数流程图1:按姓名查询cout<<"输入要查询的姓名:";cin»ming;message b30;fstream sp("wenjia n. txt",ios:i n|ios:out);for(j=0,i=0;i<temp;i+)if(strcmp(bi. name, min g)=0)cout<&
14、lt;"姓名籍贯职务部门身份证号工号基本工资岗位工资奖金医 疗住房基金税金 "<<e ndl;bi.put();2. 按工号查询:cout<<" 输入要查询的工号 :"cin>>nu;message b30;for(i=0;i<temp;i+)if(bi.number=nu)奖金 医cout<<" 姓名 籍贯 职务 部门 身份证号 工号 基本工资 岗位工资 疗住房基金 税金 "<<endl;bi.put();(7) 统计函数流程图开始1.按部门统计for(j=0,i=0
15、;i<temp;i+)if(strcmp(bi.bume n, a_bume n)=0)sum=sum+bi.basesalary+alary+bi.jiangjin-bi.yljj-bi.sj; / 实发工 资ui=bi.basesalary+alary+bi.jia ngji n-bi.yljj-bi.sj;j+;int max;int min;max=u0;min=u0;int bb;for(i=0;i<temp;i+) if(Ui>max) bb=Ui; Ui=max; max=bb; / 最高工资for(i=0;i<temp;i+)
16、 if(Ui<min) bb=Ui; Ui=min; min=Ui; / 最低工资for(i=0;i<temp;i+) bi.basesalary=abs(sum/(j+0.0)-bi.basesalary); / 工资均方差 sum1=sum1+bi.basesalary;2. 单位统计int U20;for(i=0;i<20;i+)Ui=0; for(j=0,i=0;i<temp;i+) sum=sum+bi.basesalary+alary+bi.jiangjin-bi.yljj-bi.sj; / 实 发 工 资Ui=bi.basesalary+bi
17、.jobsalary+bi.jiangjin-bi.yljj-bi.sj;j+;int max;int min; max=U0;min=U0;int bb;for(i=0;i<temp;i+) if(Ui>max) bb=Ui; Ui=max; max=bb; / 最高工资for(i=0;i<temp;i+) if(Ui<min) bb=Ui; Ui=min; min=Ui; / 最低工资 for(i=0;i<temp;i+) bi.basesalary=abs(sum/(j+0.0)-bi.basesalary); / 工资均方差 sum1=sum1+bi.ba
18、sesalary;四、调试分析1、开始使用文件保存时出现不能为 read 错误,后通过查阅资料解决了问题;flag2、删除部分程序开始不能判断是否找到了要删除的人员信息,后来加了 标记后可以判断了;3、统计部分程序在求均方差的时候出现算法错误,后来查阅了均方差公式后改 正了过来4、使用友员函数可以解决类外作用域问题。五、用户手册1. 本程序的运行环境为 doc 操作系统;2进入界面后,按照提示输入选择;3. 选择 1:执行工资信息录入操作;4. 选择 2:执行工资信息添加操作;5. 选择 3:执行工资信息删除操作;6. 选择 4:执行工资信息修改操作;7. 选择 5:执行工资信息查询操作;8.
19、 选择 6:执行工资信息统计操作;9. 选择 7:退出工资管理系统;10. 输入后按回车键,即可输出信息,按提示输入即可。六、测试数据( 1)选择 1:工资录入选择( 2):添加工资信息(3)选择 3:删除工资信息(4)选择 4:修改工资信息(5)选择 5:查找工资信息( 6)选择 6:统计工资信息(7)选择 7:退出七、附录#include"iostream.h"#include "stdlib.h"#include "stdio.h"#include"string.h"#include"message
20、.h"class messageprivate:char bornplace10,duty10; / 籍贯 职务int ID; / 身份证号public:char name10,bumen10; / 姓名 部门int number; / 工号int basesalary;/ 基本工资int jobsalary; / 岗位工资int yljj; / 医疗基金int sj;/ 税金int jiangjin; / 奖金message() /* 构造函数a_ID,intvoid xinxi(char a_name,char a_bornplace,char a_duty,char a_bum
21、en,int a_number,int a_basesalary,int a_jobsalary,int a_jiangjin,int a_yljj,int a_sj)strcpy(name,a_name);strcpy(bornplace,a_bornplace);strcpy(duty,a_duty); strcpy(bumen,a_bumen); ID=a_ID;number=a_number; basesalary=a_basesalary; jobsalary=a_jobsalary;jiangjin=a_jiangjin;yljj=a_yljj;sj=a_sj;message &a
22、mp;operator=(const message &s) /* 运算符重载strcpy(name,); strcpy(bornplace,s.bornplace);strcpy(duty,s.duty);strcpy(bumen,s.bumen);ID=s.ID;number=s.number;basesalary=s.basesalary;jobsalary=alary;jiangjin=s.jiangjin;yljj=s.yljj;sj=s.sj;return * this;friend void modify(int x); /* 友元函数 frien
23、d int del(int x);void put()/ 定义 put 函数,以便于其他函数的调用cout<<name<<" "<<bornplace<<" "<<duty<<" "<<bumen<<" "<<ID<<" "<<number<<" "<<basesalary<<" "<
24、<jobsalary<<" "<<jiangjin<<" "<<yljj<<" "<<sj<<endl;析构message();void main()int i,b;int or;cout<<"* 欢迎进入企业工资管理系统 *"<<endl;cout<<"cout<<"cout<<"cout<<"工资信息录入操作 工
25、资信息增加操作 工资信息删除操作 工资信息修改操作*"<<endl;*"<<endl;*"<<endl;*"<<endl;cout<<"*5.工资信息查找操作 *"<<endl;cout<<"*6.工资信息统计操作 *"<<endl;cout<<"*7.退出 *"<<endl;cout<<"* 请输入你要进行的操作选项 *"<<end
26、l; cin>>i;cout<<endl;while(i!=10)switch(i) default:cout<<" 你输入的有误,请重新输入。 "<<endl;break; case 1:cout<<"输入企业人员的人数:"/输入信息 cin>>b;cout<<endl;writein(b); break;case 2:/添加add(b); b+; break;case 3:/删除del(b);b-;break;case 4:/修改modify(b);break;cas
27、e 5:/查询cout<<" |1"<<endl;cout<<"情输入您要选择的查询方式:| "<<endl;cout<<" |按姓名查找操作| "<<endl;cout<<" |按工号查找操作| "<<endl;cout<<" 11"<<e ndl;cin>>or;if(or=1)namfind(b);else if(or=2)numfind(b);break;c
28、ase 6:/统计int cc;cout<<" i1"<<e ndl;cout<<"情输入您要选择的查询方式:| "<<endl;cout<<" | 按部门统计| "<<endl;cout<<" | 按单位统计| "<<endl;cout<<" 11"<<e ndl;/cin>>or; :cin>>cc;if(cc=1) bmcount(b);else
29、if(cc=2)dwcount();break;case 7:exit(0);cout<<"*"<<endl;cout<<"*1.工资信息录入操作*"<<endl;*2.工资信息增加操作*"<<endl;*3.工资信息删除操作*"<<endl;*4.工资信息修改操作*"<<endl;*5.工资信息查找操作*"<<endl;*6.工资信息统计操作*"<<endl;*7.退出 *"<&l
30、t;endl;欢迎进入企业工资管理系统cout<<"*cout<<"*cout<<"*cout<<"*cout<<"*cout<<"*请输入你要进行的操作选项 *"<<endl;cout<<"*cin>>i;cout<<endl;void writein(int x) / 工资信息录入部门 基本工message a10;char a_name10,a_bornplace10,a_duty10,a_
31、bumen10; / 姓名 籍贯 职务 int j,a_ID,a_basesalary,a_jobsalary,a_jiangjin,a_yljj,a_sj,a_number; / 身份证号 资 岗位工资 奖金 医疗住房基金 税金fstream f("wenjian.txt",ios:out); / 打开文件if(!f)cout<<"Can not open filen."for(j=0;j<x;j+)cout<<" 姓名: "<<endl;cin>>a_name;cout<
32、<" 籍贯 : "<<endl;cin>>a_bornplace;cout<<" 职务 : "<<endl; cin>>a_duty;cout<<" 部门 : "<<endl; cin>>a_bumen;cout<<" 身份证号 : "<<endl; cin>>a_ID;cout<<" 工号 : "<<endl; cin>>
33、a_number;cout<<" 基本工资 : "<<endl; cin>>a_basesalary;cout<<" 岗位工资 : "<<endl; cin>>a_jobsalary;cout<<" 奖金 : "<<endl; cin>>a_jiangjin;cout<<" 医疗住房基金 : "<<endl; cin>>a_yljj;cout<<" 税
34、金 : "<<endl; cin>>a_sj;cout<<endl;aj.xinxi(a_name,a_bornplace,a_duty,a_bumen,a_ID,a_number,a_basesalary,a_jobsalary,a_ji angjin,a_yljj,a_sj);f.write(char *)&aj,sizeof(aj ); / 保存录入的信息f.close(); / 关闭文件 cout<<endl;ifstream in("wenjian.txt",ios:in); message b10
35、;for(j=0;j<x;j+)if(!in.eof()in.read(char *)&bj,sizeof(aj);bj.put();else exit(0);in.close();void add(int x) / 工资信息添加char a_name10,a_bornplace10,a_duty10,a_bumen10;int a_ID,a_basesalary,a_jobsalary,a_jiangjin,a_yljj,a_sj,a_number,temp=30;message c;cout<<" 输入要增加的人员的信息 :"<<e
36、ndl; cout<<" 姓名 : "<<endl;cin>>a_name;cout<<" 籍贯 : "<<endl;cin>>a_bornplace;cout<<"职务:"<<endl;cin>>a_duty;cout<<" 部门 : "<<endl;cin>>a_bumen;cout<<" 身份证号 : "<<endl;cin
37、>>a_ID;cout<<" 工号 : "<<endl;cin>>a_number;cout<<"基本工资:"<<endl;cin>>a_basesalary;cout<<" 岗位工资 : "<<endl;cin>>a_jobsalary;cout<<"奖金:"<<endl;cin>>a_jiangjin;cout<<"医疗住房基金:&qu
38、ot;<<endl;cin>>a_yljj;cout<<" 税金 : "<<endl;cin>>a_sj;cout<<endl;c.xinxi(a_name,a_bornplace,a_duty,a_bumen,a_ID,a_number,a_basesalary,a_jobsalary,a_jian gjin,a_yljj,a_sj);ofstream out("wenjian.txt",ios:app);out.write(char *)&c,sizeof(class m
39、essage); / 保存到文件中out.close();cout<<"增加成功!"<<endl;int del(int x) / 工资信息删除int i,j,temp,flag=-1;char ming10;system("cls");ifstream in("wenjian.txt");message b30,c;for(j=0;j<30;j+)if(!in.eof()in.read(char *)&bj,sizeof(class message);elsetemp = j-1;break;c
40、out<<" 文件内保存的信息有 :"<<endl; / 输出文件内的人员信息工资cout<<" 姓名地址 职务 部门 身份证号 工号"<<endl;for(j=0;j<temp;j+)bj.put();in.close();fstream sp("wenjian.txt",ios:in|ios:out);for(j=0;j<30;j+)if(!sp.eof()sp.read(char *)&bj,sizeof(class message);elsetemp = j-
41、1;break;sp.close();message a30;fstream ap("wenjian.txt",ios:in|ios:out); cout<<" 请输入要删除人员信息的名字 :" cin>>ming;cout<<endl; for(j=0,i=0;i<temp;i+)if(strcmp(,ming)=0) / 标记要删除的信息 flag=i; if(flag=-1)cout<<" 没有要删除的信息。 "<<endl; return 0;fo
42、r(j=0,i=0;i<temp,j<temp-1; ) / 删除信息if(flag!=i) aj=bi; i+; j+;else i+;ap.close();ofstream np("wenjian.txt");for(i=0;i<temp-1;i+)np.write(char *)&ai,sizeof(class message); / 写入文件 np.close();cout<<" 删除成功 !"<<endl;return 1;void modify(int x) / 工资信息修改char ming
43、10;int i,j,temp,flag;message b30;ifstream sp("wenjian.txt");for(j=0;j<30;j+)if(!sp.eof()sp.read(char *)&bj,sizeof(class message); / 打开文件 else temp = j-1; break;sp.close();cout<<" 输入要修改人的名字 :"cin>>ming;cout<<endl;cout<<" 原文件信息是 :"<<en
44、dl;for(i=0;i<temp;i+) / 输出文件内保存的信息 if(strcmp(,ming)=0)flag = i; bi.put(); cout<<endl; cout<<flag<<endl; cout<<endl;cout<<" 请输入修改信息 :"<<endl;cout<<" 姓名 : "<<endl; cin>>; cout<<" 籍贯 : "<<
45、;endl; cin>>bflag.bornplace; cout<<"职务:"<<endl; cin>>bflag.duty; cout<<" 部门 : "<<endl; cin>>bflag.bumen; cout<<" 身份证号 : "<<endl; cin>>bflag.ID; cout<<" 工号 : "<<endl; cin>>bflag.numbe
46、r; cout<<"基本工资:"<<endl; cin>>bflag.basesalary; cout<<" 岗位工资 : "<<endl; cin>>alary; cout<<"奖金:"<<endl; cin>>bflag.jiangjin;cout<<"医疗住房基金:"<<endl; cin>>bflag.yljj;cout<<"
47、; 税金 : "<<endl;cin>>bflag.sj;cout<<endl;ofstream in("wenjian.txt"); for(i=0;i<temp;i+) if(!in)cout<<"Can not open!"<<endl;in.write(char *)&bi,sizeof(class message); cout<<endl; in.close();void namfind(int x) / 按姓名查找操作int j,temp,i;ch
48、ar ming10;cout<<" 输入要查询的姓名 :"cin>>ming;cout<<endl;cout<<" 这个人的信息是 :"<<endl; message b30;fstream sp("wenjian.txt",ios:in|ios:out);for(j=0;j<30;j+)if(!sp.eof()sp.read(char *)&bj,sizeof(class message);elsetemp = j-1;break; for(j=0,i=0;i
49、<temp;i+)if(strcmp(,ming)=0)奖金 医cout<<" 姓名 籍贯 职务 部门 身份证号 工号 基本工资 岗位工资 疗住房基金 税金 "<<endl;bi.put();sp.close();void numfind(int x) / 按工号查找操作int nu,i,j,temp;cout<<" 输入要查询的工号 :"cin>>nu;cout<<endl;cout<<" 这个人的信息是 :"<<endl; me
50、ssage b30;fstream sp("wenjian.txt",ios:in|ios:out); for(j=0;j<30;j+)if(!sp.eof()sp.read(char *)&bj,sizeof(class message);elsetemp = j-1;break;for(i=0;i<temp;i+)if(bi.number=nu)奖金 医cout<<" 姓名 籍贯 职务 部门 身份证号 工号 基本工资 岗位工资 疗住房基金 税金 "<<endl;bi.put();sp.close(); vo
51、id bmcount(int x) / 按部门统计操作int i,j,sum=0,sum1=0,temp;char a_bumen10;cout<<" 请输入要统计的部门 :"cin>>a_bumen;cout<<endl;message b30;fstream sp("wenjian.txt",ios:in|ios:out);for(j=0;j<30;j+)if(!sp.eof()sp.read(char *)&bj,sizeof(class message);elsetemp = j-1;break;int U20;for(i=0;i&
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 短视频电商促销活动合规宣传规范考核试卷
- 解析卷人教版八年级上册物理声现象《声音的特性》专题测试试卷(含答案详解版)
- 难点解析人教版八年级物理上册第6章质量与密度-质量综合测评试题
- 2025年多晶硅5S纯度控制考核试卷
- 2025年侵犯公民人身权利、民主权利罪公诉考核试卷
- 2025年虚拟电厂2025年政策规范解读考核试卷
- 综合解析人教版八年级上册物理《物态变化》难点解析练习题(含答案详解)
- 支架式教学在高中英语写作教学中的应用研究
- 2024年重金属污染预警监测技术考核试卷
- 供用热合同(标准版)
- 美团客服接待流程
- 论《平凡的世界》中的苦难意识
- 质保监查培训课件
- 2024年货运代理合同货运代理详细协议
- 颈椎病术后康复训练
- (一模)韶关市2025届高三综合测试(一)语文试卷(含答案详解)
- 《信息安全技术 数据安全风险评估方法》
- 北京市昌平区2025届九年级物理上学期期中试题
- 钢结构施工合同范本
- 苏少版八年级下册美术:第8课-一目了然
- 中国传统美学工艺点翠
评论
0/150
提交评论