资源描述
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
using namespace std;
const A=2;
const B=4;
int a,b,c,d,s;
class employee //员工(基类)
{
protected:
string name;
int num;
int age;
char sex;
double pay;
public:
employee()
{ name="\0";
num=0;
age=0;
sex='\0';
pay=0;}
void set()
{
cout<<"其姓名:";
cin>>name;
cout<<"性别(M/W):";
cin>>sex;
cout<<"年龄:";
cin>>age;
}
int get1()
{
return num;
}
string get2()
{
return name;
}
char get3()
{
return sex;
}
int get4()
{
return age;
}
double payment()
{
return pay;
}
};
class technician:public employee //技术员
{
protected:
int workhour;
public:
void set()
{
cout<<"技术员旳编号:";
cin>>num;
employee::set();
cout<<"工作时间:";
cin>>workhour;
cout<<endl;
pay=100*workhour;
}
};technician te[A];
class manager:public employee //经理
{
public:
void set()
{
cout<<"经理旳编号:";
cin>>num;
employee::set();
cout<<endl;
}
int get()
{
return 8000;
}
};manager mana[A];
class seller:public employee //销售员
{
protected:
double sell;
int managernum;
public:
void set()
{
cout<<"销售员旳编号:";
cin>>num;
employee::set();
cout<<"销售额:";
cin>>sell;
cout<<"所属销售经理旳编号:";
cin>>managernum;
pay=sell*0.04;
cout<<endl;
}
int get5()
{
return managernum;
}
double get6()
{
return sell;
}
void tongji()
{
cout<<"│"<<setw(12)<<num<<"│"<<setw(12)<<name<<"│"<<setw(12)<<sell<<"│"<<endl;
}
};seller se[B];
class sellmanager:public employee //销售经理
{
protected:
int sumsale;
public:
void set()
{
cout<<"销售经理旳编号:";
cin>>num;
employee::set();
cout<<endl;
for (int i=0;i<B;i++)
if (num==se[i].get5())
{
sumsale=sumsale+se[i].get6();
}
pay=5000+sumsale*0.005;
}
void tongji()
{
cout<<"职工号为 "<<num<<" 销售经理 "<<name<<" 下属销售员旳业绩为:"<<endl;
cout<<"┌──────┬──────┬──────┐"<<endl;
cout<<"│"<<setw(12)<<"职工号"<<"│"<<setw(12)<<"姓名"<<"│"<<setw(12)<<"销售额 "<<"│"<<endl;
}
};sellmanager semana[A];
void line()
{
cout<<"-------------------------------------"<<endl<<endl;
}
void shuru1()
{
for(a=0;a<A;a++)
te[a].set();
line();
}
void shuru2()
{
for(a=0;a<A;a++)
mana[a].set();
line();
}
void shuru3()
{
for(b=0;b<B;b++)
se[b].set();
line();
}
void shuru4()
{
for(a=0;a<A;a++)
semana[a].set();
line();
}
void mulu()
{
cout<<" ★★小型企业工资管理系统★★ "<<endl;
cout<<"┌───────────────┐"<<endl;
cout<<"│ 请选择您所需旳操作 │"<<endl;
cout<<"│ 数据输入:1,并按回车键 │"<<endl;
cout<<"│ 数据记录:2,并按回车键 │"<<endl;
cout<<"│ 数据打印:3,并按回车键 │"<<endl;
cout<<"│ 数据备份:4,并按回车键 │"<<endl;
cout<<"│ 退出系统:5,并按回车键 │"<<endl;
cout<<"└───────────────┘"<<endl;
cout<<"请选择一种操作:";
cin>>c;
cout<<endl;
}
void cijimulu()
{
cout<<" ★★小型企业工资管理系统★★ "<<endl;
cout<<"┌────────────────┐"<<endl;
cout<<"│ 请选择您所需旳操作 │"<<endl;
cout<<"│技术员数据输入: 1,并按回车键 │"<<endl;
cout<<"│经理数据输入: 2,并按回车键 │"<<endl;
cout<<"│销售员数据输入: 3,并按回车键 │"<<endl;
cout<<"│销售经理数据输入:4,并按回车键 │"<<endl;
cout<<"│返回上一级: 5,并按回车键 │"<<endl;
cout<<"└────────────────┘"<<endl;
cout<<"请选择一种操作:";
cin>>d;
cout<<endl;
}
void biaotou()
{
cout<<"┌──────┬──────┬──────┬──────┬──────┐"<<endl;
cout<<"│"<<setw(12)<<"职工号"<<"│"<<setw(12)<<"姓名"<<"│"<<setw(12)<<"性别"<<"│"<<setw(12)<<"年龄"<<"│"<<setw(12)<<"工资"<<"│"<<endl;
}
void biaozhong()
{
cout<<"├──────┼──────┼──────┼──────┼──────┤"<<endl;
}
void biaowei()
{
cout<<"└──────┴──────┴──────┴──────┴──────┘"<<endl;
}
void tongji()
{
int a,b,s;
for(a=0;a<A;a++)
{
s=0;
semana[a].tongji();
for(b=0;b<B;b++)
{
if(se[b].get5()==semana[a].get1())
{
cout<<"├──────┼──────┼──────┤"<<endl;
se[b].tongji();
s=s+se[b].get6();
}
}
cout<<"├──────┼──────┴──────┤"<<endl;
cout<<"│"<<setw(8)<<"销售额总计: "<<"│ "<<setw(21)<<s<<" │"<<endl;
cout<<"└──────┴─────────────┘"<<endl;
}
cout<<"销售经理按工资排序为:"<<endl;
biaotou();
for(int i=0;i<A-1;i++)
{
for(int j=i+1;j<A;j++)
if(semana[i].payment()<semana[j].payment())
{sellmanager g;
g=semana[i];
semana[i]=semana[j];
semana[j]=g;
}
}
for (int k=0;k<A;k++)
{
biaozhong();
cout<<"│"<<setw(12)<<semana[k].get1()<<"│"<<setw(12)<<semana[k].get2()<<"│"<<setw(12)<<semana[k].get3()<<"│"<<setw(12)<<semana[k].get4()<<"│"<<setw(12)<<semana[k].payment()<<"│"<<endl;
}
biaowei();
}
void daying()
{
int k;
cout<<"请等待......."<<endl<<endl;
cout<<"职工基本状况一览表如下"<<endl<<endl;
cout<<"技术员"<<endl<<endl;
biaotou();
for(k=0;k<A;k++)
{
biaozhong();
cout<<"│"<<setw(12)<<te[k].get1()<<"│"<<setw(12)<<te[k].get2()<<"│"<<setw(12)<<te[k].get3()<<"│"<<setw(12)<<te[k].get4()<<"│"<<setw(12)<<te[k].payment()<<"│"<<endl;
}
biaowei();
line();
cout<<"经理"<<endl<<endl;
biaotou();
for(k=0;k<A;k++)
{
biaozhong();
cout<<"│"<<setw(12)<<mana[k].get1()<<"│"<<setw(12)<<mana[k].get2()<<"│"<<setw(12)<<mana[k].get3()<<"│"<<setw(12)<<mana[k].get4()<<"│"<<setw(12)<<mana[k].get()<<"│"<<endl;
}
biaowei();
line();
cout<<"销售经理"<<endl<<endl;
biaotou();
for(k=0;k<A;k++)
{
biaozhong();
cout<<"│"<<setw(12)<<semana[k].get1()<<"│"<<setw(12)<<semana[k].get2()<<"│"<<setw(12)<<semana[k].get3()<<"│"<<setw(12)<<semana[k].get4()<<"│"<<setw(12)<<semana[k].payment()<<"│"<<endl;
}
biaowei();
line();
cout<<"销售员"<<endl<<endl;
cout<<"┌────┬────┬────┬────┬────┬──────────┐"<<endl;
cout<<"│"<<setw(8)<<"职工号"<<"│"<<setw(8)<<"姓名"<<"│"<<setw(8)<<"性别"<<"│"<<setw(8)<<"年龄"<<"│"<<setw(8)<<"工资"<<"│"<<setw(20)<<"所属部门经理"<<"│"<<endl;
for(k=0;k<B;k++)
{
cout<<"├────┼────┼────┼────┼────┼──────────┤"<<endl;
cout<<"│"<<setw(8)<<se[k].get1()<<"│"<<setw(8)<<se[k].get2()<<"│"<<setw(8)<<se[k].get3()<<"│"<<setw(8)<<se[k].get4()<<"│"<<setw(8)<<se[k].payment()<<"│"<<setw(20)<<se[k].get5()<<"│"<<endl;
}
cout<<"└────┴────┴────┴────┴────┴──────────┘"<<endl<<endl;
cout<<"------------------------------------------------"<<endl<<endl;
}
void beifen()
{
ofstream myfile("qt.txt");
int k;
cout<<"请等待......."<<endl<<endl;
myfile<<"职工基本状况一览表如下"<<endl<<endl;
myfile<<"技术员"<<endl<<endl;
myfile<<"┌──────┬──────┬──────┬──────┬──────┐"<<endl;
myfile<<"│"<<setw(12)<<"职工号"<<"│"<<setw(12)<<"姓名"<<"│"<<setw(12)<<"性别"<<"│"<<setw(12)<<"年龄"<<"│"<<setw(12)<<"工资"<<"│"<<endl;
for(k=0;k<A;k++)
{
myfile<<"├──────┼──────┼──────┼──────┼──────┤"<<endl;
myfile<<"│"<<setw(12)<<te[k].get1()<<"│"<<setw(12)<<te[k].get2()<<"│"<<setw(12)<<te[k].get3()<<"│"<<setw(12)<<te[k].get4()<<"│"<<setw(12)<<te[k].payment()<<"│"<<endl;
}
myfile<<"└──────┴──────┴──────┴──────┴──────┘"<<endl;
myfile<<"经理"<<endl<<endl;
myfile<<"┌──────┬──────┬──────┬──────┬──────┐"<<endl;
myfile<<"│"<<setw(12)<<"职工号"<<"│"<<setw(12)<<"姓名"<<"│"<<setw(12)<<"性别"<<"│"<<setw(12)<<"年龄"<<"│"<<setw(12)<<"工资"<<"│"<<endl;
for(k=0;k<A;k++)
{
myfile<<"├──────┼──────┼──────┼──────┼──────┤"<<endl;
myfile<<"│"<<setw(12)<<mana[k].get1()<<"│"<<setw(12)<<mana[k].get2()<<"│"<<setw(12)<<mana[k].get3()<<"│"<<setw(12)<<mana[k].get4()<<"│"<<setw(12)<<mana[k].get()<<"│"<<endl;
}
myfile<<"└──────┴──────┴──────┴──────┴──────┘"<<endl;
myfile<<"销售经理"<<endl<<endl;
myfile<<"┌──────┬──────┬──────┬──────┬──────┐"<<endl;
myfile<<"│"<<setw(12)<<"职工号"<<"│"<<setw(12)<<"姓名"<<"│"<<setw(12)<<"性别"<<"│"<<setw(12)<<"年龄"<<"│"<<setw(12)<<"工资"<<"│"<<endl;
for(k=0;k<A;k++)
{
myfile<<"├──────┼──────┼──────┼──────┼──────┤"<<endl;
myfile<<"│"<<setw(12)<<semana[k].get1()<<"│"<<setw(12)<<semana[k].get2()<<"│"<<setw(12)<<semana[k].get3()<<"│"<<setw(12)<<semana[k].get4()<<"│"<<setw(12)<<semana[k].payment()<<"│"<<endl;
}
myfile<<"└──────┴──────┴──────┴──────┴──────┘"<<endl;
myfile<<"销售员"<<endl<<endl;
myfile<<"┌────┬────┬────┬────┬────┬──────────┐"<<endl;
myfile<<"│"<<setw(8)<<"职工号"<<"│"<<setw(8)<<"姓名"<<"│"<<setw(8)<<"性别"<<"│"<<setw(8)<<"年龄"<<"│"<<setw(8)<<"工资"<<"│"<<setw(20)<<"所属部门经理"<<"│"<<endl;
for(k=0;k<B;k++)
{
myfile<<"├────┼────┼────┼────┼────┼──────────┤"<<endl;
myfile<<"│"<<setw(8)<<se[k].get1()<<"│"<<setw(8)<<se[k].get2()<<"│"<<setw(8)<<se[k].get3()<<"│"<<setw(8)<<se[k].get4()<<"│"<<setw(8)<<se[k].payment()<<"│"<<setw(20)<<se[k].get5()<<"│"<<endl;
}
myfile<<"└────┴────┴────┴────┴────┴──────────┘"<<endl<<endl;
}
int main()
{
while (c!=5)
{
mulu();
line();
switch(c)
{
case 1:
while (d!=5)
{
cijimulu();
line();
switch(d)
{
case 1:
shuru1();
continue;
case 2:
shuru2();
continue;
case 3:
shuru3();
continue;
case 4:
shuru4();
continue;
}
}
continue;
case 2:
tongji();
continue;
case 3:
daying();
continue;
case 4:
beifen();
continue;
}
}
return 0;
}
展开阅读全文