⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 5.txt

📁 企业职工工资管理系统 是小型的企业职工工资管理系统 代码较少
💻 TXT
字号:
#include<iostream.h>

#include<stdlib.h>

#include<fstream.h>

#include<iomanip.h>

#include<string.h>

class employee

{

public: 

float salary;

employee()

{

salary=0;

}

void pay(){}

void print(){}

void input()

{

cout<<"的编号:";

cin>>no;

cout<<" 其姓名:";

cin>>name;

cout<<" 性别(m/w):";

cin>>sex;

cout<<" 年龄:"; 

cin>>age;

}

protected:

int no;

char name[8];



char sex;

int age;



};

class manager:virtual public employee

{

protected:

float monthlypay,sale;

public:



manager(){monthlypay=8000;}

void input(){cout<<"经理";employee::input();}

void save()

{

fstream outfile;

outfile.open("F:shuju.txt",ios::app);

if(!outfile)

{

cout<<"F can't open.\n";

abort();

}

outfile<<"经理"<<endl;

outfile<<"号码"<<no<<"名字"<<name<<"性别"<<sex<<"年龄"<<age<<"工资"<<salary<<endl;

}

void pay(){salary=monthlypay;}

void print()

{

cout<<"├—————┼—————┼—————┼—————┼—————┤"<<endl;

cout<<"│"<<setw(10)<<no<<"│"<<setw(10)<<name<<"│"<<setw(10)<<sex\

<<"│"<<setw(10)<<age<<"│"<<setw(10)<<salary<<"│"<<endl;

}

};



class technician:virtual public employee

{

private:

float hourlyrate;

int workhours;

public:

technician(){hourlyrate=100;}

void pay()

{

cout<<name<<"本月工作时数:";

cin>>workhours;

salary=hourlyrate*workhours;

}

void input(){cout<<"技术工"<<endl;employee::input();}

void save()

{

fstream outfile;

outfile.open("F:shuju.txt",ios::app);

if(!outfile)

{

cout<<"F can't open.\n";

abort();

}

outfile<<"技术工"<<endl;

outfile<<"号码"<<no<<"名字"<<name<<"性别"<<sex<<"年龄"<<age<<"工资"<<salary<<endl;

}

void print()

{

cout<<"├—————┼—————┼—————┼—————┼—————┤"<<endl;

cout<<"│"<<setw(10)<<no<<"│"<<setw(10)<<name<< "│"<<setw(10)<<sex\

<<"│"<<setw(10)<<age<<"│"<<setw(10)<<salary<<"│"<<endl;

}

};

class salesman:virtual public employee

{

protected:

float commrate;

float sales;

public:

salesman(){commrate=0.04;}

void input(){cout<<"销售员";employee::input();}

void save()

{

fstream outfile;

outfile.open("F:shuju.txt",ios::app);

if(!outfile)

{

cout<<"f can't open.\n";

abort();

}

outfile<<"技术工"<<endl;

outfile<<"号码"<<no<<"名字"<<name<<"性别"<<sex<<"年龄"<<age<<"工资"<<salary<<endl;

}

void pay()

{

cout<<name<<"本月销售额:";

cin>>sales;

salary=sales*commrate;

}

void print()

{

cout<<"├—————┼—————┼—————┼—————┼—————┤"<<endl;

cout<<"│"<<setw(10)<<no<<"│"<<setw(10)<<name<<"│"<<setw(10)\

<<sex<<"│"<<setw(10)<<age<<"│"<<setw(10)<<salary<<"│"<<endl;

}

};



class salesmanager:virtual public manager,virtual public salesman

{

private:

float total;int no1,no2,no3,no4;char name1[8],name2[8],name3[8],name4[8];

float sale1,sale2,sale3,sale4;

public:

int flag;

void salemanager()

{

monthlypay=5000;

commrate=0.005;

}

void input(){cout<<"销售经理";employee::input();}

void save()

{

fstream outfile;

outfile.open("F:shuju.txt",ios::app);

if(!outfile)

{

cout<<"f can't open.\n";

abort();

}

outfile<<"销售经理"<<endl;

outfile<<"号码"<<no<<"名字"<<name<<"性别"<<sex<<"年龄"<<age<<"工资"<<salary<<endl;

}

void savesale()

{

fstream outfile;

outfile.open("F:shuju.txt",ios::app);

if(!outfile)

{

cout<<"F can't open.\n";

abort();

}

outfile<<"销售经理所辖售员业绩及自己的工资"<<endl;

outfile<<"编号"<<no1<<"名字"<<name1<<"工资"<<sale1<<endl;

outfile<<"编号"<<no2<<"名字"<<name2<<"工资"<<sale2<<endl;

outfile<<"编号"<<no3<<"名字"<<name3<<"工资"<<sale3<<endl;

outfile<<"编号"<<no4<<"名字"<<name4<<"工资"<<sale4<<endl;

}

int min(float salary1,float salary2)

{

if(salary1<salary2)

return 1;

else return 2;

}

void pay()

{



salemanager();

salary=monthlypay+commrate*totalsale();

}

float totalsale()

{total=sale1+sale2+sale3+sale4;return total;}

void printtotal()

{

cout<<"├—————┴——┬——┴—————┤"<<endl;

cout<<"│销售额合计 │ "<<setw(10)<<total<<" │"<<endl;

cout<<"└————————┴————————┘"<<endl;

}

void sort(salesmanager &p)

{

int tmp,i,j;

for(j=0;j<2;j++)

for(i=0;i<2;i++)

if(total<p.salary)

{

tmp=salary;

total=p.salary;

p.salary=tmp;

tmp=no;

no=p.no;

p.no=tmp;

}

}

void saler()

{

cout<<name<<"所管部门月销售量:";

cout<<"职工编号:";

cin>>no1;

cout<<" 职工姓名:";

cin>>name1;

cout<<" 销售额:";

cin>>sale1;

cout<<"职工编号:";

cin>>no2;

cout<<" 职工姓名:";

cin>>name2;

cout<<" 销售额:";

cin>>sale2;

cout<<"职工编号:";

cin>>no3;

cout<<" 职工姓名:";

cin>>name3;

cout<<" 销售额:";

cin>>sale3;

cout<<"职工编号:";

cin>>no4;

cout<<" 职工姓名:";

cin>>name4;

cout<<" 销售额:";

cin>>sale4;



}

void saleprint()

{

cout<<"│"<<setw(10)<<no1<<"│"<<setw(10)<<name1<<"│"<<setw(10)<<sale1<<"│"<<endl;

cout<<"├—————┼—————┼—————┤"<<endl;

cout<<"│"<<setw(10)<<no2<<"│"<<setw(10)<<name2<<"│"<<setw(10)<<sale2<<"│"<<endl;

cout<<"├—————┼—————┼—————┤"<<endl;

cout<<"│"<<setw(10)<<no3<<"│"<<setw(10)<<name3<<"│"<<setw(10)<<sale3<<"│"<<endl;

cout<<"├—————┼—————┼—————┤"<<endl;

cout<<"│"<<setw(10)<<no4<<"│"<<setw(10)<<name4<<"│"<<setw(10)<<sale4<<"│"<<endl;

}

void print()

{

cout<<"├—————┼—————┼—————┼—————┼—————┤"<<endl;

cout<<"│"<<setw(10)<<no<<"│"<<setw(10)<<name<<"│"<<setw(10)<<sex<<"│"

<<setw(10)<<age<<"│"<<setw(10)<<salary<<"│"<<endl;

}

};

void main()

{

manager m[4];

technician t[4];

salesman s[4];

salesmanager sm[4];

t[1].save();

int flag=1,operate,minnum=0;

do{

cout<<" ★★小型公司工资管理系统★★\n";

cout<<" ┌—————————————┐\n"; 

cout<<" │ 请选择您所需的操作 │\n";

cout<<" │ 数据输入:1,并按回车键 │\n";

cout<<" │ 数据统计:2,并按回车键 │\n";

cout<<" │ 数据打印:3,并按回车键 │\n";

cout<<" │ 数据备份:4,并按回车键 │\n";

cout<<" │ 退出系统:5,并按回车键 │\n";

cout<<" └—————————————┘\n"; 

cout<<" 请选择一个操作: ";

cin>>operate;

switch(operate)

{

case 1:

cout<<"please waiting........"<<endl;

{

for(int i=0;i<4;i++)

{m[i].input();}

for(int j=0;j<4;j++)

{t[j].input();}

for(int k=0;k<4;k++)

{s[k].input();} 

for(int l=0;l<4;l++)

{sm[l].input();}

}

{

for(int i=0;i<4;i++)

{m[i].pay();}

for(int j=0;j<4;j++)

{t[j].pay();}

for(int k=0;k<4;k++)

{s[k].pay();}

for(int l=0;l<4;l++)

{sm[l].saler();sm[l].pay();}

};break;

case 2:

cout<<"please waiting......."<<endl;

{

{

for(int l=0;l<4;l++)

sm[l].totalsale();





};



cout<<" 第一位经理的销售员"<<endl;

cout<<"┌—————┬—————┬——————┐"<<endl;

cout<<"│ 职工号 │ 姓名 │ 销售额 │"<<endl;

sm[0].saleprint();

sm[0].printtotal(); 

cout<<" 排序已经完成"<<endl;

cout<<"各销售经理的排名"<<endl;

cout<<"┌—————┬—————┬—————┬—————┬———————┐"<<endl;

cout<<"│ 职工号 │ 姓名 │ 性别 │ 年龄 │ 工资 │"<<endl;

for(int i=0;i<4;i++)

{

minnum=0;

for(int ddd=0;ddd<4;ddd++)

{ 

if(sm[minnum].salary>sm[ddd].salary&&sm[ddd].flag!=1)

{

minnum=ddd;

}

}

sm[minnum].flag=1;

sm[minnum].print();

}

cout<<"└—————┴—————┴—————┴—————┴———————┘"<<endl;

};break;



case 3:

cout<<"please waiting........"<<endl;

{

cout<<"*********************************************************************"<<endl;

cout<<" 经理工资一览表如下:"<<endl;

cout<<"┌—————┬—————┬—————┬—————┬——————┐"<<endl;

cout<<"│ 职工号 │ 姓名 │ 性别 │ 年龄 │ 工资 │"<<endl;

for(int i=0;i<4;i++)

{m[i].print();}

cout<<"└—————┴—————┴—————┴—————┴——————┘"<<endl;



cout<<"*********************************************************************"<<endl;

cout<<" 技术员的月工资一览表:"<<endl;

cout<<"┌—————┬—————┬—————┬—————┬——————┐"<<endl;

cout<<"│ 职工号 │ 姓名 │ 性别 │ 年龄 │ 工资 │"<<endl;

for(int j=0;j<4;j++)

{t[j].print();}

cout<<"└—————┴—————┴—————┴—————┴——————┘"<<endl;



cout<<"********************************************************************"<<endl;

cout<<" 销售员工资一览表"<<endl;

cout<<"┌—————┬—————┬—————┬—————┬———————┐"<<endl;

cout<<"│ 职工号 │ 姓名 │ 性别 │ 年龄 │ 工资 │"<<endl;

for(int k=0;k<4;k++)

{s[k].print();}

cout<<"└—————┴—————┴—————┴—————┴———————┘"<<endl;



cout<<"********************************************************************"<<endl;

cout<<" 销售经理工资一览表"<<endl;

cout<<"┌—————┬—————┬—————┬—————┬———————┐"<<endl;

cout<<"│ 职工号 │ 姓名 │ 性别 │ 年龄 │ 工资 │"<<endl;

for(int l=0;l<4;l++)

{sm[l].print();}

cout<<"└—————┴—————┴—————┴—————┴———————┘"<<endl;

};break;



case 4:

cout<<"please waiting........"<<endl; 

{

for(int i=0;i<4;i++)

{m[i].save();}

for(int j=0;j<4;j++)

{t[j].save();}

for(int k=0;k<4;k++)

{s[k].save();}

for(int l=0;l<4;l++)

{sm[l].save();}

};

cout<<"information have been saved!"<<endl;

break;

case 5:exit(0);break; 

default:cout<<"输入错误,请重新1-5间的输入"<<endl;

}

}while(flag=1); 

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -