C++小型企业工资管理系统.docx
- 文档编号:26494028
- 上传时间:2023-06-20
- 格式:DOCX
- 页数:20
- 大小:85.50KB
C++小型企业工资管理系统.docx
《C++小型企业工资管理系统.docx》由会员分享,可在线阅读,更多相关《C++小型企业工资管理系统.docx(20页珍藏版)》请在冰豆网上搜索。
C++小型企业工资管理系统
一、需求分析
1.从要求上来看是要对各个员工的各种情况(名字、年龄、性别、职位、工资状况)进行输入。
然后可以输出.
2.可以对于员工数据进行修改,可以查询.
3.对于员工的各种情况系统还可以进行统计排名.
二、概要设计
首先,创建了一个employee类.然后派生出四个类:
manager、technician、salesman、salesmanager.在派生类中定义了三个构造函数,分别是:
数据输入函数(Input),表格输出函数(Print),排序函数(Pay).
其次,在总体结构上,建立以各根菜单,用于选择各种功能.
1.Input(数据输入):
输入员工的各种数据.
2.Total(数据统计):
将员工的总数据进行对比排序,然后输出.
3.Output(数据显示):
显示输入的各种数据.
4.Save(数据保存):
对输入的数据进行保存备份.
5.Eixt(退出程序):
执行退出程序命令.
三、详细设计
1.Input(数据输入):
定义了各个岗位的人员的类,并把每个类的人员的属性设为类中的保护成员,其中技术工的工作时间和每小时的所得为私有成员,而销售员的销售额、经理的工资和销售经理的所辖部门的销售额和其底薪设为公有成员,再依次录入。
2.Total(数据统计):
根据所有类的工资算法在其所属类中定义一个函数voidpay()来根据各个职位的具体情况来计算工资,并且算出的工资经过冒泡法排序.
voidprinttotal()
{
cout<<"├─────┴──┬──┴─────┤"< cout<<"│Total │ "< cout<<"└────────┴────────┘"< } 3.Output(数据显示): 通过do-while循环以及制表格和setw的使用将输入的数据和统计并排序的数据以表格的形式打印出来,销售额合计一栏宽度要大些。 voidsaleprint() { cout<<"│"< cout<<"├─────┼─────┼─────┤"< cout<<"│"< cout<<"├─────┼─────┼─────┤"< cout<<"│"< cout<<"├─────┼─────┼─────┤"< cout<<"│"< } voidprint() { cout<<"├─────┼─────┼─────┼─────┼─────┤"< cout<<"│"< < } 4.Save(数据保存): 通过函数save()来将输入的数据和统计并排序的数据进行保存.例如: voidsave() { fstreamoutfile; outfile.open("f: flsdfj.txt",ios: : app); if(! outfile) { cout<<"fcan'topen.\n"; abort(); } outfile<<"Salesmanger"< outfile<<"ID"< } 5.Eixt(退出): 利用exit来完成退出系统功能。 四、设计和调试分析 程序清单: #include #include #include #include #include classemployee { public: employee() { salary=0; } voidpay(){} voidprint(){} voidinput() { cout<<"ID: "; cin>>no; cout<<"NAME: "; cin>>name; cout<<"SEX(m/w): "; cin>>sex; cout<<"AGE: "; cin>>age; } protected: intno; charname[8]; floatsalary; charsex; intage; }; classmanager: virtualpublicemployee { protected: floatmonthlypay,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"< outfile<<"ID"< } voidpay(){salary=monthlypay;} voidprint() { cout<<"├─────┼─────┼─────┼─────┼─────┤"< cout<<"│"< <<"│"< } }; classtechnician: virtualpublicemployee { private: floathourlyrate; intworkhours; public: technician(){hourlyrate=100;} voidpay() { cout< "; cin>>workhours; salary=hourlyrate*workhours; } voidinput(){cout<<"TECHNICIAN"< : input();} voidsave() { fstreamoutfile; outfile.open("f: flsdfj.txt",ios: : app); if(! outfile) { cout<<"fcan'topen.\n"; abort(); } outfile<<"TECHNICIAN"< outfile<<"ID"< } voidprint() { cout<<"├─────┼─────┼─────┼─────┼─────┤"< cout<<"│"< <<"│"< } }; classsalesman: virtualpublicemployee { protected: floatcommrate; 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"< outfile<<"ID"< } voidpay() { cout< "; cin>>sales; salary=sales*commrate; } voidprint() { cout<<"├─────┼─────┼─────┼─────┼─────┤"< cout<<"│"< < } }; classsalesmanager: virtualpublicmanager,virtualpublicsalesman { private: floattotal;intno1,no2,no3,no4;charname1[8],name2[8],name3[8],name4[8]; floatsale1,sale2,sale3,sale4; public: voidsalemanager() { monthlypay=5000; commrate=0.005; } voidinput(){cout<<"Salesmanger";employee: : input();} voidsave() { fstreamoutfile; outfile.open("f: flsdfj.txt",ios: : app); if(! outfile) { cout<<"fcan'topen.\n"; abort(); } outfile<<"Salesmanger"< outfile<<"ID"< } voidsavesale() { fstreamoutfile; outfile.open("f: flsdfj.txt",ios: : app); if(! outfile) { cout<<"fcan'topen.\n"; abort(); } outfile<<"Thesalaryofsalemanofsalesmangerandthemselves"< outfile<<"ID"< outfile<<"ID"< outfile<<"ID"< outfile<<"ID"< } voidpay() { cout< "; salary=monthlypay+commrate*total; } floattotalsale(){total=sale1+sale2+sale3+sale4;returntotal;} voidprinttotal() { cout<<"├─────┴──┬──┴─────┤"< cout<<"│Total │ "< cout<<"└────────┴────────┘"< } voidsort(salesmanagerp) { inttmp,i,j; for(j=0;j<2;j++) for(i=0;i<2;i++) if(total { 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<<"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>>name4; cout<<"Salesvolume: "; cin>>sale4; } voidsaleprint() { cout<<"│"< cout<<"├─────┼─────┼─────┤"< cout<<"│"< cout<<"├─────┼─────┼─────┤"< cout<<"│"< cout<<"├─────┼─────┼─────┤"< cout<<"│"< } voidprint() { cout<<"├─────┼─────┼─────┼─────┼─────┤"< cout<<"│"< < } }; voidmain() { managerm[4]; techniciant[4]; salesmans[4]; salesmanagersm[4]; t[1].save(); intflag=1,operate; do{ cout<<"####Thesystemofsalarymanger####\n"; cout<<"┌─────────────┐\n"; cout<<"│Choseyouractions│\n"; cout<<"│Input: 1,Enter│\n"; cout<<"│Total: 2,Enter│\n"; cout<<"│Output: 3,Enter│\n"; cout<<"│Save: 4,Enter│\n"; cout<<"│Exit: 5,Enter│\n"; cout<<"└─────────────┘\n"; cout<<"Pleasechoseoneaction: "; cin>>operate; switch(operate) { case1: cout<<"Waitingforaminute! "< { for(inti=0;i<4;i++) {m[i].input();} for(intj=0;j<4;j++) {t[j].input();} for(intk=0;k<4;k++) {s[k].input();} for(intl=0;l<4;l++) {sm[l].input();} }; { for(inti=0;i<4;i++) {m[i].pay();} for(intj=0;j<4;j++) {t[j].pay();} for(intk=0;k<4;k++) {s[k].pay();} for(intl=0;l<4;l++) {sm[l].pay();sm[l].saler();} };break; case2: cout<<"Waitingforaminute! "< { { for(intl=0;l<4;l++) sm[l].totalsale(); for(inti=0;i<4;i++) for(intj=0;j<2;j++) sm[j].sort(sm[j+1]); }; cout<<"Thesalemanofthefirstsalesmanger"< cout<<"┌─────┬─────┬─────┐"< cout<<"│ ID │ NAME │SALARY│"< sm[0].saleprint(); sm[0].printtotal(); cout<<"Theorderiscomplete"< cout<<"Listnamesofeverysalesmanger"< cout<<"┌─────┬─────┬─────┬─────┬─────┐"< cout<<"│ ID │ NAME │ SEX │ AGE │SALARY │"< for(intk=0;k<4;k++) sm[k].print(); cout<<"└─────┴─────┴─────┴─────┴─────┘"< };break; case3: cout<<"Waitingforaminute! "< { cout<<"Theblankofthe: "< cout<<"┌─────┬─────┬─────┬─────┬─────┐"< cout<<"│ ID │ NAME │ SEX │ AGE │SALARY │"< for(inti=0;i<4;i++) {m[i].print();} cout<<"└─────┴─────┴─────┴─────┴─────┘"< cout<<"┌─────┬─────┬─────┬─────┬─────┐"< cout<<"└─────┴─────┴─────┴─────┴─────┘"< cout<<"┌─────┬─────┬─────┬─────┬─────┐"< cout<<"│ ID │ NAME │ SEX │ AGE │SALARY │"< for(intk=0;k<4;k++) {s[k].print();} cout<<"└─────┴─────┴─────┴─────┴─────┘"< cout<<"┌─────┬─────┬─────┬─────┬─────┐"< cout<<"└─────┴─────┴─────┴─────┴─────┘"< };break; case4: cout<<"Waitingforaminute! "< { for(inti=0;i<4;i++) {m[i].save();} for(intj=0;j<4;j++) {t[j].save();} for(intk=0;k<4;k++) {s[k].save();} for(intl=0;l<4;l++) {sm[l].save();} };cout<<"Informationsave! "< case5: exit(0);break; default: cout<<"Error! Repeatagain! "<
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- C+ 小型企业 工资管理 系统