编写一个程序实现小型公司的工资管理。该公司主要有四类人员:经理(manager)、技术人员(technician),销售员(salesman),销售经理(salesmanager),这些人员都是职员(employee),有编号,姓名,月工资信息。月工资的计算方法是:经理固定月薪8000元,技术人员每小时100元,销售员按当月销售额的4%提成,销售经理既拿固定月工资5000元也拿销售提成,销售提成为所管辖部门当月销售额的千分之五。要求编程计算职员的月工资并显示全部信息。
#include<iostream>
#include <iomanip>
using namespace std;
class Employee
{ public:
string jobnumber,name;
double salary;
Employee(){}
void Basicinformation(){
cout<<"请输入工号:";
cin>>jobnumber;
cout<<"请输入你的姓名:";
cin>>name;
}
void Output(){
cout<<"您的基本信息如下:"<<endl;
cout<<"工号:"<<jobnumber<<endl;
cout<<"姓名:"<<name<<endl;
cout<<fixed<<showpoint<<setprecision(2);
cout<<"薪水:"<<setprecision(2)<<salary<<endl;
}
};
class Manager : public Employee{
public:
void Salary()
{
salary=10000;
}
};
class Technician : public Employee{
private:
int a;
public:
Technician(){}
void Sethour(){
cout<<"请输入你的工作时间:";
cin>>a;
}
void Salary(){
salary=100*a;
}
};
class Salesman : public Employee{
private:
double saleroom;
public:
Salesman(){}
void Setsaleroom(){
cout<<"请输入你的销售额:";
cin>>saleroom;
}
void Salary(){
salary=saleroom*0.04;
}
};
class Salesmanager : public Employee{
private:
double saleroom;
public:
Salesmanager(){}
void Setsaleroom(){
cout<<"请输入你的员工的总销售额:"<<endl;
cin>>saleroom;
}
void Salary(){
salary=saleroom*0.005+5000;
}
};
int main(){
int a;
cout<<"请输入您的工作类别:"<<"\n如果你是经理请输入1、如果你是技术人员请输入2"<<endl;
cout<<"如果你是销售人员请输入3、如果你是销售经理请输入4"<<endl;
cin>>a;
while(a<1||a>4){
cout<<"输入错误,请从新输入:"<<endl;
cin>>a;
}
if(a==1){
Manager b;
b.Basicinformation();
b.Salary();
b.Output();
}
else if(a==2){
Technician b;
b.Basicinformation();
b.Sethour();
b.Salary();
b.Output();
}
else if(a==3){
Salesman b;
b.Basicinformation();
b.Setsaleroom();
b.Output();
}
else{
Salesmanager b;
b.Basicinformation();
b.Setsaleroom();
b.Salary();
b.Output();
}
return 0;
}