C++小型公司管理系统 公司有雇员,经理,技术人员,销售经理;储存这些人员的姓名、编号、年龄、性别、工资;

这是一个C++实现的员工信息管理系统,包括经理、销售经理、技术人员和销售人员类。系统能够输入和输出不同职位员工的详细信息,如发薪日期、姓名、编号、级别、工资等,并且对销售经理的工资进行特殊计算。此外,还提供了根据员工类型筛选并输出信息的功能。
摘要由CSDN通过智能技术生成

具体代码如下:

#include<iostream>
using namespace std;
class date
 {public:
 	int year1;
 	int month1;
 	int day1;
 	date()=default;
 	date(int year,int month,int day):year1(year),month1(month),day1(day){}
  };
class employee                                                        //员工类 
{public:
	string name;
	string number;
	int rank;                                                        //级别 
	double wage;
	int age;
	string title;  
	date date1;  
	void input1();  
	void output1();                                              //日期对象 
	employee()=default;
	employee(string name,string number,int rank,int age,double wage,string title,int year,int month,int day):name(name),number(number),rank(rank),age(age),wage(wage),title(title),date1(year,month,day){}
   // void output();
    ~employee(); 
    string class1;
    int n;
	};
	employee::~employee()                                                   //基类析构函数 
	{
	}
	void employee::input1()                                                        //经理输入函数 
{
cout<<"请输入发薪时间"<<endl;
cout<<"年:"<<endl;
cin>>date1.year1;
getchar();
cout<<"月:"<<endl;
cin>>date1.month1;
cout<<"日:"<<endl;
cin>>date1.day1;
cout<<"名字:"<<endl;
cin>>name;
cout<<"编号:"<<endl;
cin>>number;
cout<<"年龄:"<<endl;
cin>>age;
}
void employee::output1() 
{cout<<(date1).year1<<"年"<<(date1).month1<<"月"<<(date1).day1<<"日"<<endl; 
}
 class manager:virtual public employee                                       //派生经理类 
 {public:
 void input();
 manager()=default;
 //date date1;
 manager(string name,string number,int rank,int age,double wage,string title,int year,int month,int day):employee(name,number,rank,age,wage,title,year,month,day){}
};

void manager::input()                                                        //经理输入函数 
{
input1();
rank=4;
wage=8000;
class1="经理";
}


class technician:virtual public employee                                           //派生技术人员类 
{public:
	void input();
	double time;
	date date1;
	technician()=default;
	technician(string name,string number,int rank,int age,double wage,string title,int year,int month,int day,double time):employee(name,number,rank,age,wage,title,year,month,day),date1(year,month,day),time(time){}
};
void technician::input()
{input1();
cout<<"工作时间:"<<endl;
cin>>time;
wage=time*100;
rank=3;
class1="技术人员";
}


class salesman:virtual public employee//派生类销售人员 
{public:
	void input();
	salesman()=default;
	date date1;
	salesman(string name,string number,int rank,int age,double wage,string title,int year,int month,int day):employee(name,number,rank,age,wage,title,year,month,day),date1(year,month,day){}
};
void salesman::input()
{input1();
double b;
cout<<"请输入该销售员的销售额:"<<endl;
cin>>wage; 
rank=1;
class1="销售员";
}


class salesmanager:virtual public salesman,virtual public manager              //间接派生类 销售经理 
{
public:
void input();
salesmanager()=default;
date date1;
salesmanager(string name,string number,int rank,int age,double wage,string title,int year,int month,int day):employee(name,number,rank,age,wage,title,year,month,day),date1(year,month,day){}
};

void salesmanager::input()
{input1();
rank=4;
class1="销售经理";
}
                                                                                //类已结束 
void output(manager *manager1,salesman *salesman1,technician *technician1,salesmanager *salesmanager1,int n,int j)   //输出函数                                               //输出函数 
{int i;
cout<<"各个段位的人的工资情况:"<<endl; 
for(i=0;i<=n;i++)
{if(j==2)
{
cout<<"经理"<<"薪资情况"<<endl;
(*(manager1+i)).output1();
cout<<"名字:"<<(*(manager1+i)).name<<endl;
cout<<"编号:"<<(*(manager1+i)).number<<endl;
cout<<"级别:"<<(*(manager1+i)).rank<<endl;
cout<<"工资:"<<(*(manager1+i)).wage<<endl;
cout<<endl;
}
if(j==4)
{
cout<<"销售员"<<"薪资情况"<<endl;
(*(salesman1+i)).output1();
cout<<"名字:"<<(*(salesman1+i)).name<<endl;
cout<<"编号:"<<(*(salesman1+i)).number<<endl;
cout<<"级别:"<<(*(salesman1+i)).rank<<endl;
cout<<"工资:"<<(*(salesman1+i)).wage<<endl;
cout<<endl;
}
if(j==3)
{
cout<<"技术人员"<<"薪资情况"<<endl;
(*(technician1+i)).output1();
cout<<"名字:"<<(*(technician1+i)).name<<endl;
cout<<"编号:"<<(*(technician1+i)).number<<endl;
cout<<"级别:"<<(*(technician1+i)).rank<<endl;
cout<<"工资:"<<(*(technician1+i)).wage<<endl;
cout<<endl;
}
if(j==1)
{
cout<<"销售经理"<<"薪资情况"<<endl;
(*(salesmanager1+i)).output1();
cout<<"名字:"<<(*(salesmanager1+i)).name<<endl;
cout<<"编号:"<<(*(salesmanager1+i)).number<<endl;
cout<<"级别:"<<(*(salesmanager1+i)).rank<<endl;
cout<<"工资:"<<(*(salesmanager1+i)).wage<<endl;
cout<<endl;
}
	}
}
                                                                                  
  double compute(salesman *p,int d)                                                     //通过销售员的销售额计算工资
  {double wage=0;
  int i;
  for(i=0;i<=d;i++)
  {
  	
  wage=wage+(*(p+i)).wage;
  wage=5000+wage*5/100;} 
  return wage;} 
  
  
  double input(salesmanager *q,manager *m,technician *t,salesman *p,int &a,int &b,int &c,int &d)            //输入函数 
  {here:
  	   here1:
  cout<<"1、经理 2、销售经理  3、技术人员  4、销售人员"<<endl;
  int i;
  int j1=0,j2=0,j3=0,j4=0; 
  cin>>i; 
  if(i<=0||i>=5)
  goto here1;     
                                                                         
  if(i==2) //销售经理 
  {there1:
   b++;
   j1++;
  (*(q+j1)).input();
  cout<<"固定工资之外,提成由销售人员的销售总额决定"<<endl; 
  cout<<"1、继续 2、结束该类成员的录入"<<endl;
  cin>>i;
  if(i==1)
  goto there1;
  }
  
  //销售员 
  if(i==4)
  {
  there2:
  	d++;
  	j2++;
  (*(p+j2)).input();
  cout<<"1、继续 2、结束该类成员的录入"<<endl;
  cin>>i;
  if(i==1)
  goto there2;
  if(i==2)
  {cout<<"确定销售人员的销售额都输完了吗,这会影响到销售经理的工资哟"<<endl;
  getchar(); 
  }
  }
  
  if(i==1)//经理 
  {there3:
  	a++;
  	j3++;
  (*(m+j3)).input();
  cout<<"1、继续 2、结束该类成员的录入"<<endl;
  cin>>i;
  if(i==1)
  goto there3;
  }
  
  if(i==3)//技术人员 
  {
  there4:
  	c++;
  	j4++;
  (*(t+j4)).input();
  cout<<"1、继续 2、结束该类成员的录入"<<endl;
  cin>>i;
  if(i==1)
  goto there4;
  }
  if(i==2)
  {cout<<"是否录入其他成员  1、继续  2、结束录入"<<endl;
  cin>>i;
  if(i==1)
  goto here;
  }
  }                                                                       //输入函数结束 
  
  int main()
  {salesmanager salesmanager1[100]{salesmanager("张三","123456",4,35,8500,"销售经理",2022,5,6)};
  salesman salesman1[100]={salesman("李四","123453",1,25,6000,"销售人员",2022,5,6)};
  manager manager1[100]={manager("王先生","123341",4,35,8000,"经理",2022,5,6)};
  technician technician1[100]={technician("李先生","131213",3,30,6500,"技术人员",2022,5,6,10)};
  
  
  salesmanager *q=&salesmanager1[0];
  manager *m=&manager1[0];
  technician *t=&technician1[0];
  salesman *p=&salesman1[0];
  int i;
  int n1=0,n2=0,n3=0,n4=0;
  int &a=n1;
  int &b=n2,&c=n3,&d=n4;
  input(q,m,t,p,a,b,c,d);
  for(i=0;i<=b;i++)
  salesmanager1[i].wage=compute(p,d);
  output(m,p,t,q,b,1);
  output(m,p,t,q,a,2);
  output(m,p,t,q,c,3);
  output(m,p,t,q,d,4);
  return 0;
  } 
  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值