C++小型企业工资管理系统_第1页
C++小型企业工资管理系统_第2页
C++小型企业工资管理系统_第3页
已阅读5页,还剩7页未读, 继续免费阅读

下载本文档

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

文档简介

1、1. 一、需求分析从要求上来看是要对各个员工的各种情况(名字、年龄、性别、职位、工资状况)进行输入。然后可以输出.2. 可以对于员工数据进行修改,可以查询.3. 对于员工的各种情况系统还可以进行统计排名.二、概要设计首先,创建了一个employee类.然后派生出四个类:managertechnician、salesman、salesmanager.在派生类中定义了三个构造函数分别是:数据输入函数(Input),表格输出函数(Print),排序函数(Pay).其次,在总体结构上,建立以各根菜单,用于选择各种功能.1. Input(数据输入):输入员工的各种数据.2. Total(数据统计):将员

2、工的总数据进行对比排序,然后输出.3. Output(数据显示):显示输入的各种数据.4. Save(数据保存):对输入的数据进行保存备份.5. Eixt(退出程序):执行退出程序命令.1. 三、详细设计Input(数据输入):定义了各个岗位的人员的类,并把每个类的人员的届性设为类中的保护成员,其中技术工的工作时间和每小时的所得为私有成员,而销售员的销售额、经理的工资和销售经理的所辖部门的销售额和其底薪设为公有成员,再依次录入。Total(数据统计):根据所有类的工资算法在其所届类中定义一个函数voidpay()来根据各个职位的具体情况来计算工资,并且算出的工资经过冒泡法排序.voidprin

3、ttotal()(cout<<""<<endl;cout<<"Total"<<setw(10)<<total<<""<<endl;cout<<""<<endl;Output(数据显示):通过do-while循环以及制表格和setw的使用将输入的数据和统计并排序的数据以表格的形式打印出来,销售额合计一栏宽度要大些。voidsaleprint()(cout<<"I"<<

4、setw(10)<<no1<<"I"<<setw(10)<<name1<<"I"<<setw(10)<<sale1<<"|"<<endl;cout<<"|111"<<endl;cout<<"|"<<setw(10)<<no2<<"|"<<setw(10)<<name2<

5、<"|"<<setw(10)<<sale2<<"|"<<endl;cout<<"|111"<<endl;cout<<"|"<<setw(10)<<no3<<"|"<<setw(10)<<name3<<"|"<<setw(10)<<sale3<<"I"<&l

6、t;endl;cout<<"|111"<<endl;cout<<"|"<<setw(10)<<no4<<"|"<<setw(10)<<name4<<"|"<<setw(10)<<sale4<<"|"<<endl;voidprint()(cout<<"|111I1"<<endl;2. cout<

7、<"|"<<setw(10)<<no<<"|"<<setw(10)<<name<<"|"<<setw(10)<<sex<<"|<<setw(10)<<age<<"|"<<setw(10)<<salary<<"<<endl;Save(数据保存):通过函数save()来将输入的数据和统计并排序的数据进行保

8、存.例如:voidsave()fstreamoutfile;outfile.open("f:flsdfj.txt",ios:app);if(!outfile)cout<<"fcan'topen.n"abort();outfile<<"Salesmanger"<<endl;outfile<<"ID"<<no<<"NAME"<<name<<"SEX"<<sex<

9、;<"AGE"<<age<<"SALARY"<<salary<<endl;3. Eixt(退出):利用exit来完成退出系统功能。四、设计和调试分析程序活单:#include<iostream.h>#include<stdlib.h>#include<fstream.h>#include<iomanip.h>#include<string.h>classemployeepublic:employee()salary=0;voidpay()vo

10、idprint()voidinput()cout<<"ID:"cin>>no;cout<<"NAME:"cin>>name;cout<<"SEX(m/w):"cin>>sex;cout<<"AGE:"cin>>age;protected:intno;charname8;floatsalary;charsex;intage;;classmanager:virtualpublicemployeeprotected:float

11、monthlypay,sale;public:manager()monthlypay=8000;voidinput()cout<<"Manger”;employee:input();voidsave()fstreamoutfile;outfile.open("f:flsdfj.txt”,ios:app);if(!outfile)cout<<"fcan'topen.n"abort();outfile<<"Manger"<<endl;outfile<<"ID&q

12、uot;<<no<<"NAME"<<name<<"SEX"<<sex<<"AGE"<<age<<"SALARY"<<salary<<endl;voidpay()salary=monthlypay;voidprint()cout<<"|111I1"<<endl;cout<<"I"<<setw(10)<<

13、;no<<"|"<<setw(10)<<name<<"|<<"|"<<setw(10)<<age<<"|"<<setw(10)<<salary<<<<endl;classtechnician:virtualpublicemployeeprivate:floathourlyrate;intworkhours;public:technician()hourlyrate=100;voidp

14、ay()cout<<name<<"Workhour:"cin>>workhours;salary=hourlyrate*workhours;voidinput()cout<<"TECHNICIAN"<<endl;employee:input();voidsave()fstreamoutfile;outfile.open("f:flsdfj.txt”,ios:app);if(!outfile)cout<<"fcan'topen.n"abort();

15、outfile<<"TECHNICIAN"<<endl;outfile<<"ID"<<no<<"NAME"<<name<<"SEX"<<sex<<"AGE"<<age<<"SALARY"<<salary<<endl;voidprint()cout<<"|111I1"<<endl;

16、cout<<"I"<<setw(10)<<no<<"|"<<setw(10)<<name<<"I<<"|"<<setw(10)<<age<<"|"<<setw(10)<<salary<<"|"<<endl;classsalesman:virtualpublicemployeeprotected:floatco

17、mmrate;floatsales;public:salesman()commrate=0.04;voidinput()cout<<"SALEMAN"employee:input();voidsave()fstreamoutfile;outfile.open("f:flsdfj.txt",ios:app);if(!outfile)cout<<"fcan'topen.n"abort();outfile<<"TECHNICIAN"<<endl;outfile<

18、;<"ID"<<no<<"NAME"<<name<<"SEX"<<sex<<"AGE"<<age<<"SALARY"<<salary<<endl;voidpay()cout<<name<<"Salesvolume:"cin>>sales;salary=sales*commrate;voidprint()cout<

19、;<"|111I1"<<endl;cout<<"|"<<setw(10)<<no<<"|"<<setw(10)<<name<<”|<<sex<<"|"<<setw(10)<<age<<”|"<<setw(10)<<salary<<"|"<<endl;classsalesmanag

20、er:virtualpublicmanager,virtualpublicsalesmanprivate:floattotal;intno1,no2,no3,no4;charname18,name28,name38,name48;floatsale1,sale2,sale3,sale4;public:voidsalemanager()monthlypay=5000;commrate=0.005;voidinput()(cout<<"Salesmanger"employee:input();voidsave()(fstreamoutfile;outfile.ope

21、n("f:flsdfj.txt",ios:app);if(!outfile)(cout<<"fcan'topen.n"abort();outfile<<"Salesmanger"<<endl;outfile<<"ID"<<no<<"NAME"<<name<<"SEX"<<sex<<"AGE"<<age<<&

22、quot;SALARY"<<salary<<endl;voidsavesale()(fstreamoutfile;outfile.open("f:flsdfj.txt",ios:app);if(!outfile)(cout<<"fcan'topen.n"abort();outfile<<"Thesalaryofsalemanofsalesmangerandthemselves"<<endl;outfile<<"ID"<&

23、lt;no1<<"NAME"<<name1<<"SALARY"<<sale1<<endl;outfile<<"ID"<<no2<<"NAME"<<name2<<"SALARY"<<sale2<<endl;outfile<<"ID"<<no3<<"NAME"<<name

24、3<<"SALARY"<<sale3<<endl;outfile<<"ID"<<no4<<"NAME"<<name4<<"SALARY"<<sale4<<endl;voidpay()(cout<<name<<"Thesalesvolumeofeverydepartment:"salary=monthlypay+commrate*total;floatto

25、talsale()total=sale1+sale2+sale3+sale4;returntotal;voidprinttotal()cout<<"|1111"<<endl;cout<<"|Total|"<<setw(10)<<total<<”"<<endl;cout<<"111"<<endl;voidsort(salesmanagerp)inttmp,i,j;for(j=0;j<2;j+)for(i=0;i&l

26、t;2;i+)if(total<p.salary)tmp=salary;total=p.salary;p.salary=tmp;tmp=no;no=p.no;p.no=tmp;voidsaler()cout«"StaffID:"cin»no1:cout«"StaffNAME:"cin»name1;cout«"Salesvolume:"cin»sale1:cout«"StaffID:"cin»no2;cout«"

27、StaffNAME:"cin»name2;cout«"Salesvolume:"cin»sale2;cout«"StaffID:"cin»no3;cout«"StaffNAME:"cin»name3;cout«"Salesvolume:"cin»sale3;cout«"StaffID:"cin»no4;cout«"StaffNAME:"cin

28、87;name4;cout«"Salesvolume:"cin»sale4;voidsaleprint()I"«setw(10)«name1«"cout«"|"«setw(10)«no1«""«setw(10)«sale1«"|"«endl;cout<<"|111"<<endl;cout<<"|&quo

29、t;<<setw(10)<<no2<<"|"<<setw(10)<<name2<<"|<<setw(10)<<sale2<<"|"<<endl;cout<<"|111"<<endl;cout<<"|"<<setw(10)<<no3<<"|"<<setw(10)<<name3

30、<<"|<<setw(10)<<sale3<<"|"<<endl;cout<<"|111"<<endl;cout<<"|"<<setw(10)<<no4<<"|"<<setw(10)<<name4<<"|<<setw(10)<<sale4<<"|"<<endl;v

31、oidprint()cout<<"|111k1"<<endl;cout<<"|"<<setw(10)<<no<<"|"<<setw(10)<<name<<"|<<setw(10)<<sex<<"|<<setw(10)<<age<<"|"<<setw(10)<<salary<<&quo

32、t;|"<<endl;voidmain()managerm4;techniciant4;salesmans4;salesmanagersm4;t1.save();intflag=1,operate;docout<<"#Thesystemofsalarymanger#n"cout<<"n"cout<<"IChoseyouractionsIn"cout<<"Input:1,EnterIn"cout<<"Total:2,Enter

33、In"cout<<"Output:3,EnterIn"cout<<"Save:4,EnterIn"cout<<"Exit:5,EnterIn"cout<<"1n"cout<<"Pleasechoseoneaction:"cin>>operate;switch(operate)(case1:cout<<"Waitingforaminute!"<<endl;(for(inti

34、=0;i<4;i+)mi.input();for(intj=0;j<4;j+)tj.input();for(intk=0;k<4;k+)sk.input();for(intl=0;l<4;l+)sml.input();for(inti=0;i<4;i+)mi.pay();for(intj=0;j<4;j+)tj.pay();for(intk=0;k<4;k+)sk.pay();for(intl=0;l<4;l+)sml.pay();sml.saler();break;case2:cout<<"Waitingforaminut

35、e!"<<endl;for(intl=0;l<4;l+)sml.totalsale();for(inti=0;i<4;i+)for(intj=0;j<2;j+)smj.sort(smj+1);cout<<"Thesalemanofthefirstsalesmanger"<<endl;cout<<"i111"<<endl;cout<<"|ID|NAME|SALARY|"<<endl;sm0.saleprint();sm0.pr

36、inttotal();cout<<"Theorderiscomplete"<<endl;cout<<"Listnamesofeverysalesmanger"<<endl;cout<<"i111-n1"<<endl;cout<<"|ID|NAME|SEX|AGEISALARY|"<<endl;for(intk=0;k<4;k+)smk.print();cout<<"11111"<

37、;<endl;break;case3:cout«"Waitingforaminute!"«endl;cout«"Theblankofthe:"«endl;cout«"i111i1"«endl;cout«"|ID|NAME|SEX|AGEISALARY|"«endl;for(inti=0;i<4;i+)mi.print();)cout«"11111"«endl;COUt«&qu

38、ot;I111i1"«endl;cout«"11111"«endl;COUt«"I111i1"«endl;cout«"|ID|NAME|SEX|AGEISALARY|"«endl;for(intk=0;k<4;k+)sk.print();)cout«"11111"«endl;COUt«"I111i1"«endl;cout«"11111"

39、71;endl;);break;case4:cout«"Waitingforaminute!"«endl;for(inti=0;i<4;i+)mi.save();for(intj=0;j<4;j+)tj.save();for(intk=0;k<4;k+)sk.save();for(intl=0;l<4;l+)sml.save();cout<<"Informationsave!"<<endl;break;case5:exit(0);break;default:cout<<"Error!Repeatagain!"<<endl;while(flag=1);五、用户手册1)运行程序.会出现如下画面,按照提示进行选择.3SChos«actionsInput;t«EnterTo

温馨提示

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

评论

0/150

提交评论