#include<iostream>
#include<iomanip>
#include<fstream>
#include<string>
using namespace std;
class staff //职工信息类定义
{
protected:
char name[10]; //职工姓名
int salary; //职工工资
public:
char *getname()
{return name;}
int getsalary()
{return salary;}
};
class jsjl:public staff //技术经理
{
protected:
int level; //业务等级
public:
int getlevel()
{return level;}
void input1() //录入技术经理信息
{
cout<<"技术经理姓名:";
cin>>name;
cout<<"业务等级:";
cin>>level;
salary=5000+1000*level;
cout<<salary<<'\n';
}
};
class xsjl:public staff //销售经理
{
protected:
int profit; //总经额
public:
int getprofit()
{return profit;}
void input2() //录入销售经理信息
{
cout<<"销售经理姓名:";
cin>>name;
cout<<"总经额:";
cin>>profit;
salary=5000+(profit*3)/1000;
cout<<salary<<'\n';
}
};
class jsry:public staff //技术人员
{
protected:
int time; //工作时间
public:
int gettime()
{return time;}
void input3() //录入技术人员信息
{
cout<<"技术人员姓名:";
cin>>name;
cout<<"工作时间:";
cin>>time;
salary=40*time;
cout<<salary<<'\n';
}
};
class xsry:public staff //销售人员
{
protected:
int sale; //销售总量
public:
int getsale()
{return sale;}
void input4() //录入销售人员信息
{
cout<<"销售人员姓名:";
cin>>name;
cout<<"销售总量:";
cin>>sale;
salary=(5*sale)/100;
cout<<salary<<'\n';
}
};
class wm:public staff //文秘
{
protected:
int sale; //奖金
public:
int getsale()
{return sale;}
void input5() //录入文秘信息
{
cout<<"文秘姓名:";
cin>>name;
cout<<"奖金:";
cin>>sale;
salary=4000+sale;
cout<<salary<<'\n';
}
};
jsjl a[2];
xsjl b[2];
jsry c[6];
xsry d[6];
wm e[4];
void use(); //使用介绍
void input(); //录入职工信息函数声明
void show(); //显示职工信息函数声明
void save(); //存档
void getsave(); //打开存档
void account(); //计算当月公司总工资
int main()
{
int select;
while(1)
{
system("cls");
cout<<"\t ******************欢迎使用******************\n";
cout<<"\t ****************工资管理系统****************\n";
cout<<"\t *__________________________________________*\n";
cout<<"\t *1使用介绍 *\n";
cout<<"\t *2录入职工信息 *\n";
cout<<"\t *3显示职工信息 *\n";
cout<<"\t *4存档 *\n";
cout<<"\t *5打开存档 *\n";
cout<<"\t *6退出 *\n";
cout<<"\t *__________________________________________*\n";
cout<<"\t 你要输入的编号是(1--6):";
cin>>select;
if(select==0) break;
switch(select){
case 1:
system("cls");
use(); //使用介绍
system("pause");
break;
case 2:
system("cls");
input(); //录入职员信息
system("pause");
break;
case 3:
system("cls");
show(); //调用show函数查询职工信息
system("pause");
break;
case 4:
system("cls");
save(); //调用save函数保存职工信息
system("pause");
break;
case 5:
system("cls");
getsave(); // 调用del函数删除职工信息
system("pause");
break;
default:
system("cls");
cout<<"没有此选项,请重新选择!"<<endl;
}
}
return 0;
}
void input() //录入职工信息的函数
{
for(int i=0;i<2;i++)a[i].input1();
for(i=0;i<2;i++)b[i].input2();
for(i=0;i<6;i++)c[i].input3();
for(i=0;i<6;i++)d[i].input4();
for(i=0;i<4;i++) e[i].input5();
account();
}
void show() //显示所有职工信息函数
{
cout<<left;//设置输出左对齐
cout<<setw(20)<<"技术经理姓名"<<setw(20)<<"业绩等级"<<setw(12)<<"当月工资"<<'\n';
for(int j=0;j<2;j++)
{
cout<<setw(20)<<a[j].getname()<<setw(20)<<a[j].getlevel()<<setw(12)<<a[j].getsalary()<<'\n';
}
cout<<'\n';
cout<<setw(20)<<"销售经理姓名"<<setw(20)<<"总经额"<<setw(12)<<"当月工资"<<'\n';
for(int n=0;n<2;n++)
{
cout<<setw(20)<<b[n].getname()<<setw(20)<<b[n].getprofit()<<setw(12)<<b[n].getsalary()<<'\n';
}
cout<<'\n';
cout<<setw(20)<<"技术人员姓名"<<setw(20)<<"工作时间"<<setw(12)<<"当月工资"<<'\n';
for(int k=0;k<6;k++)
{
cout<<setw(20)<<c[k].getname()<<setw(20)<<c[k].gettime()<<setw(12)<<c[k].getsalary()<<'\n';
}
cout<<'\n';
cout<<setw(20)<<"销售人员姓名"<<setw(20)<<"销售总量"<<setw(12)<<"当月工资"<<'\n';
for(int s=0;s<6;s++)
{
cout<<setw(20)<<d[s].getname()<<setw(20)<<d[s].getsale()<<setw(12)<<d[s].getsalary()<<'\n';
}
cout<<'\n';
cout<<setw(20)<<"文秘姓名:"<<setw(20)<<"奖金:"<<setw(12)<<"当月工资:"<<'\n';
for(int m=0;m<4;m++)
{
cout<<setw(20)<<e[m].getname()<<setw(20)<<e[m].getsale()<<setw(12)<<e[m].getsalary()<<'\n';
}
cout<<'\n';
account();
}
void use()
{
cout<<"该公司有技术经理2名、销售经理2名、技术人员6名、销售人员6名和文秘4名,共20名职工。录入职工信息时需要逐一全部录入。录入相关业绩即可显示其当月工资。只有当存档以后才能打开存档。只要存档过,以后每次打开此系统都可以打开存档。"<<'\n';
}
void save()
{
ofstream outfile("data.txt",ios::out);
if(!outfile)
{
cout<<"不能打开目的文件:"<<'\n';
exit(1);
}
cout<<"存档中......"<<'\n';
outfile<<"----------------------------------------------------------------------------------------"<<'\n';
outfile<<"***技术经理的资料统计***"<<'\n';
outfile<<setw(10)<<"技术经理姓名"<<setw(10)<<"业绩等级"<<setw(10)<<"当月工资"<<'\n';
for(int i=0;i<2;i++)
{
outfile<<a[i].getname()<<setw(10)<<a[i].getlevel()<<setw(10)<<a[i].getsalary()<<'\n';
}
outfile<<"---------------------------------------------------------------------------------------"<<'\n';
outfile<<"***销售经理的资料统计***"<<'\n';
outfile<<setw(10)<<"销售经理姓名"<<setw(10)<<"总经额"<<setw(10)<<"当月工资"<<'\n';
for(int j=0;j<2;j++)
{
outfile<<setw(10)<<b[j].getname()<<setw(10)<<b[j].getprofit()<<setw(10)<<b[j].getsalary()<<'\n';
}
outfile<<"---------------------------------------------------------------------------------------"<<'\n';
outfile<<"***技术人员的资料统计***"<<'\n';
outfile<<"技术人员姓名:"<<setw(10)<<"工作时间:"<<setw(10)<<"当月工资"<<setw(10)<<'\n';
for(int k=0;i<6;k++)
{
outfile<<setw(10)<<c[k].getname()<<setw(10)<<c[k].gettime()<<setw(10)<<c[k].getsalary()<<'\n';
}
outfile<<"---------------------------------------------------------------------------------------"<<'\n';
outfile<<"***销售人员的资料统计***"<<'\n';
outfile<<setw(10)<<"销售人员姓名"<<setw(10)<<"销售总量"<<setw(10)<<"当月工资"<<'\n';
for(j=0;j<6;j++)
{
outfile<<setw(10)<<d[j].getname()<<setw(10)<<d[j].getsale()<<setw(10)<<d[j].getsalary()<<'\n';
}
outfile<<"---------------------------------------------------------------------------------------"<<'\n';
outfile<<"***文秘的资料统计***"<<'\n';
outfile<<setw(10)<<"文秘姓名"<<setw(10)<<"奖金"<<setw(10)<<"当月工资"<<'\n';
for(j=0;j<4;j++)
{
outfile<<setw(10)<<e[j].getname()<<setw(10)<<e[j].getsale()<<setw(10)<<e[j].getsalary()<<'\n';
}
outfile.close();//关闭磁盘文件“data.txt”
cout<<"存档完毕!"<<'\n';
}//向磁盘文件“data.txt”输出数据
void getsave()
{
char *filename;
cout<<"自己完善删除函数"<<endl;
}
void account()
{
int allsalary=0;
for(int i=0;i<2;i++)
allsalary+=a[i].getsalary();
for(int j=0;j<2;j++)
allsalary+=b[j].getsalary();
for(int k=0;k<6;k++)
allsalary+=c[k].getsalary();
for(int m=0;m<6;m++)
allsalary+=d[m].getsalary();
for(int n=0;n<4;n++)
allsalary+=e[n].getsalary();
cout<<'\n'<<"\t公司当月总工资(元):"<<allsalary<<'\n';
}