小型公司工资管理系统(C++)源代码(共12页).doc
精选优质文档-倾情为你奉上#include<iomanip.h>#include<iostream.h>#include<fstream.h>#include<stdlib.h>class Employ/基类-雇员类protected: int num; char name10; char sex; int age; int wage;public:virtual void set()=0;virtual void print()=0;virtual void reserved()=0;class Manager:public Employ/经理类public: void set(); void print();void reserved();class Salesman:public Employ/销售员类protected:int salesvolume;int snum;public: void set(); void print();void reserved();void printinfor();int getsales()return salesvolume;int getsnum()return snum;class MarketMan:public Manager/销售经理类protected:int salesvolume;public: void set(); void print();void reserved(); int resetwage();int getnum()return num;char*getname()return name;int getamount(Salesman s,int n)salesvolume=0;for(int i=0;i<n;i+)if(si.getsnum()=num)salesvolume+=si.getsales();return salesvolume;class Technician:public Employ/技术员类protected:int worktime;public: void set(); void print();void reserved();void Manager:set()wage=8000;cout<<"经理的编号:"cin>>num;cout<<"其姓名:"cin>>name;cout<<"性别(m/w):"cin>>sex;cout<<"年龄:"cin>>age;void Manager:print()/经理类成员函数cout<<""<<endl;cout<<""<<setw(12)<<num<<""<<setw(12)<<name<<""<<setw(12)<<sex;cout<<""<<setw(12)<<age<<""<<setw(12)<<wage<<""<<endl;void Manager:reserved()ofstream employf("E:05-29gzglxt.txt",ios:app);employf<<"经理的编号:"<<num<<endl <<"其姓名:"<<name<<endl <<"性别(m/w):"<<sex<<endl <<"年龄:"<<age<<endl;void MarketMan:set()wage=resetwage();cout<<"销售经理的编号:"cin>>num;cout<<"其姓名:"cin>>name;cout<<"性别(m/w):"cin>>sex;cout<<"年龄:"cin>>age; void MarketMan:print() resetwage();cout<<""<<endl;cout<<""<<setw(12)<<num<<""<<setw(12)<<name<<""<<setw(12)<<sex;cout<<""<<setw(12)<<age<<""<<setw(12)<<wage<<""<<endl;void MarketMan:reserved() ofstream employf("E:05-29gzglxt.txt",ios:app);employf<<"销售经理的编号:"<<num<<endl <<"其姓名:"<<name<<endl <<"性别(m/w):"<<sex<<endl <<"年龄:"<<age<<endl;int MarketMan:resetwage()wage=5000+int(salesvolume*0.005);return wage;void Salesman:set()/销售员类定义cout<<"销售员的编号:"cin>>num;cout<<"其姓名:"cin>>name;cout<<"性别(m/w):"cin>>sex;cout<<"年龄:"cin>>age;cout<<"销售额:"cin>>salesvolume;cout<<"所属销售经理的编号:"cin>>snum; wage=int(salesvolume*0.04);void Salesman:printinfor()cout<<""<<endl;cout<<""<<setw(14)<<num<<""<<setw(14)<<name<<""<<setw(14)<<salesvolume<<""<<endl;void Salesman:print()cout<<""<<endl;cout<<""<<setw(8)<<num<<""<<setw(10)<<name<<""<<setw(10)<<sex;cout<<""<<setw(10)<<age<<""<<setw(10)<<wage<<""<<setw(16)<<getsnum()<<""<<endl; void Salesman:reserved()ofstream employf("E:05-29gzglxt.txt",ios:app);employf<<"销售员的编号:"<<num<<endl <<"其姓名:"<<name<<endl <<"性别(m/w):"<<sex<<endl <<"年龄:"<<age<<endl <<"销售额:"<<salesvolume<<endl <<"所属销售经理的编号"<<snum<<endl;void Technician:set()/技术员类定义cout<<"技术员的编号:"cin>>num;cout<<"其姓名:"cin>>name;cout<<"性别(m/w):"cin>>sex;cout<<"年龄:"cin>>age;cout<<"工作时间:"cin>>worktime;wage=worktime*100; void Technician:print()cout<<""<<endl;cout<<""<<setw(12)<<num<<""<<setw(12)<<name<<""<<setw(12)<<sex;cout<<""<<setw(12)<<age<<""<<setw(12)<<wage<<""<<endl; void Technician:reserved() ofstream employf("E:05-29gzglxt.txt",ios:app);employf<<"技术员的编号:"<<num<<endl <<"其姓名:"<<name<<endl <<"性别(m/w):"<<sex<<endl <<"年龄:"<<age<<endl <<"工作时间:"<<worktime<<endl;/主函数int t,m,s,mm;Technician*pt;Manager*pm;Salesman*ps;MarketMan*pmm;void setin();void count();void printdata();void reservedall();void single();void main()cout<<"请分别输入技术员,经理,销售员,销售经理人数:"<<endl;cin>>t>>m>>s>>mm;pt=new Techniciant;pm=new Managerm;ps=new Salesmans;pmm=new MarketManmm;if(!pt)|(!pm)|(!ps)|(!pmm)cout<<"堆内存分配失败!"<<endl;exit(1);single();void single() cout<<"小型公司工资管理系统"<<endl;cout<<""<<endl;cout<<" 请选择所需的操作 "<<endl;cout<<" "<<endl;cout<<" 数据输入:1,并按回车键 "<<endl;cout<<" "<<endl;cout<<" 数据统计:2,并按回车键 "<<endl;cout<<" "<<endl;cout<<" 数据打印:3,并按回车键 "<<endl;cout<<" "<<endl;cout<<" 数据备份:4,并按回车键 "<<endl;cout<<" "<<endl;cout<<" 退出系统:5,并按回车键 "<<endl;cout<<" "<<endl;cout<<""<<endl;cout<<"请选择一个操作:"<<endl;int choice;cin>>choice;switch(choice)case 1:setin();case 2:count(); case 3:printdata();case 4:reservedall();case 5:exit(0);void setin()Menu1:cout<<"小型公司工资管理系统"<<endl;cout<<""<<endl;cout<<" 请选择所需的操作 "<<endl;cout<<" "<<endl;cout<<"技术员数据输入 : 1,并按回车键 "<<endl;cout<<" "<<endl;cout<<"经理数据输入 : 2,并按回车键 "<<endl;cout<<" "<<endl;cout<<"销售员数据输入 : 3,并按回车键 "<<endl;cout<<" "<<endl;cout<<"销售经理数据输入 : 4,并按回车键 "<<endl;cout<<" "<<endl;cout<<"返回上一级菜单 : 5,并按回车键 "<<endl;cout<<""<<endl;cout<<"请选择一个操作"int ch1,i;cin>>ch1;switch(ch1)case 1:for(i=0;i<t;i+) pti.set(); cout<<"-"<<endl; goto Menu1;case 2:for(i=0;i<m;i+) pmi.set(); cout<<"-"<<endl; goto Menu1;case 3:for(i=0;i<s;i+) psi.set(); cout<<"-"<<endl; goto Menu1; case 4:for(i=0;i<mm;i+) pmmi.set(); cout<<"-"<<endl; goto Menu1; case 5:single();void count()Menu2:cout<<"小型公司工资管理系统"<<endl;cout<<""<<endl;cout<<" 请选择所需的操作 "<<endl;cout<<" "<<endl;cout<<"各销售经理下属销售员业绩统计 : 1,并按回车键 "<<endl;cout<<" "<<endl;cout<<"销售经理按工资排序 : 2,并按回车键 "<<endl;cout<<" "<<endl;cout<<"返回上一级菜单 : 3,并按回车键 "<<endl;cout<<""<<endl;cout<<"请选择一个操作"int ch2,i,j;cin>>ch2;switch(ch2)case 1:for(i=0;i<mm;i+) cout<<"职工号为:"<<pmmi.getnum()<<"销售经理:"<<pmmi.getname()<<"下属销售员的业绩为:"<<endl; cout<<""<<endl; cout<<"职工号 姓名 销售额 "<<endl; for(j=0;j<s;j+) if(pmmi.getnum()=psj.getsnum() psj.printinfor(); cout<<""<<endl; cout<<"销售额总计: "<<setw(22)<<pmmi.getamount(ps,s)<<""<<endl; cout<<""<<endl; goto Menu2; case 2:cout<<"销售经理按工资排序为:"<<endl; MarketMan pmmm; for(i=1;i<mm;i+) for(j=0;j<mm-i;j+) if(pmmj.getamount(ps,s)<pmmj+1.getamount(ps,s) pmmm=pmmj; pmmj=pmmj+1; pmmj+1=pmmm; cout<<""<<endl; cout<<" 职工号 姓名 性别 年龄 工资 "<<endl; for(i=0;i<mm;i+) pmmi.print(); cout<<""<<endl; cout<<" -"<<endl; goto Menu2;case 3:single();void printdata()Menu3:cout<<"小型公司工资管理系统"<<endl;cout<<""<<endl;cout<<" 请选择所需的操作 "<<endl;cout<<" "<<endl;cout<<"技术员数据输出 : 1,并按回车键 "<<endl;cout<<" "<<endl;cout<<"经理数据输出 : 2,并按回车键 "<<endl;cout<<" "<<endl;cout<<"销售员数据输出 : 3,并按回车键 "<<endl;cout<<" "<<endl;cout<<"销售经理数据输出 : 4,并按回车键 "<<endl;cout<<" "<<endl;cout<<"返回上一级 : 5,并按回车键 "<<endl;cout<<""<<endl;cout<<"请选择一个操作"int ch3,i;cin>>ch3;switch(ch3)case 1: cout<<"技术员"<<endl<<endl; cout<<""<<endl; cout<<" 职工号 姓名 性别 年龄 工资 "<<endl; for(i=0;i<t;i+) pti.print(); cout<<""<<endl; cout<<"-"<<endl; goto Menu3;case 2: cout<<"经理"<<endl<<endl; cout<<""<<endl; cout<<" 职工号 姓名 性别 年龄 工资 "<<endl; for(i=0;i<m;i+) pmi.print(); cout<<""<<endl; cout<<"-"<<endl; goto Menu3;case 4:cout<<"销售经理"<<endl<<endl; cout<<""<<endl; cout<<" 职工号 姓名 性别 年龄 工资 "<<endl; for(i=0;i<mm;i+) pmmi.print(); cout<<""<<endl; cout<<"-"<<endl; goto Menu3;case 3:cout<<"销售员"<<endl<<endl; cout<<""<<endl; cout<<" 职工号 姓名 性别 年龄 工资 所属部门经理编号"<<endl; for(i=0;i<s;i+) psi.print(); cout<<""<<endl; cout<<"-"<<endl; goto Menu3;case 5:single();void reservedall()Menu4:cout<<"小型公司工资管理系统"<<endl;cout<<""<<endl;cout<<" 请选择所需的操作 "<<endl;cout<<" "<<endl;cout<<"技术员数据备份 : 1,并按回车键 "<<endl;cout<<" "<<endl;cout<<"经理数据备份 : 2,并按回车键 "<<endl;cout<<" "<<endl;cout<<"销售员数据备份 : 3,并按回车键 "<<endl;cout<<" "<<endl;cout<<"销售经理数据备份 : 4,并按回车键 "<<endl;cout<<" "<<endl;cout<<"返回上一级 : 5,并按回车键 "<<endl;cout<<""<<endl;cout<<"请选择一个操作"int ch4,i;cin>>ch4;switch(ch4)case 1:for(i=0;i<t;i+) pti.reserved(); goto Menu4; case 2:for(i=0;i<m;i+) pmi.reserved(); goto Menu4; case 3:for(i=0;i<s;i+) psi.reserved(); goto Menu4; case 4:for(i=0;i<mm;i+) pmmi.reserved(); goto Menu4; case 5:single();专心-专注-专业