用C++编程——小型公司工资管理系统

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

#include <iostream>

#include <string>

#include <iomanip>

#include <fstream>

using namespace std;

const int n=2;

class Employee

{

protected:

int num;

string name;

int age;

char sex;

double salary;

public:

Employee(int n=0,int a=0,double sa=0){num=n;age=a;salary=sa;} virtual void input();

virtual void print(){};

virtual void txtout(){} ;

int funnum(){return num;}

string funname(){return name;}

};

void Employee::input()

{

cout<<"编号:";cin>>num;

cout<<"其姓名:";cin>>name;

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

cout<<"年龄:";cin>>age;

}

class Technician:public Employee

{

protected:

int hours;

int hourlypay;

public:

Technician(int hp=100){hourlypay=hp;}

virtual void input();

virtual double pay(){return (salary=hours*hourlypay);}

virtual void print();

virtual void txtout();

};

void Technician::input()

cout<<"技术员的";

Employee::input();

cout<<"工作时间:";

cin>>hours;

}

class Manager:public Employee

{

public:

Manager(double sa=8000){salary=sa;}

virtual void input();

virtual void print();

virtual void txtout();

};

void Manager::input()

{

cout<<"经理的";

Employee::input();

}

class Salesman:public Employee

{

protected:

double commrate;//提成

int Smnum;//所属经理的编号

double sales;//销售额

public:

Salesman(double com=0.04){commrate=com;}

virtual void input();

virtual double pay(){return (salary=sales*commrate);} virtual void print();

virtual void txtout();

int funnum1(){return Smnum;}

double funsales(){return sales;}

};

void Salesman::input()

{

cout<<"销售员的";

Employee::input();

cout<<"销售额:";

cin>>sales;

cout<<"所属销售经理的编号:";cin>>Smnum;

class Salesmanager:public Employee

{

protected:

double basepay,sumsales,commrate;//底薪,销售总额,提成

public:

Salesmanager(double base=5000,double com=0.005)

{basepay=base;commrate=com;}

virtual void input();

virtual void print();

virtual void print1();

virtual void pay();

virtual void shujutongji();

virtual void txtout();

};

Technician tec[n];Manager man[n];Salesman sal[2*n];Salesmanager sma[n];//定义全局变量

void Salesmanager::input()

{

cout<<"销售经理的";

Employee::input();

}

void Salesmanager::pay()

{

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

{

sma[i].sumsales=0;

for(int j=0;j<2*n;j++)

{

if(sal[j].funnum1()==sma[j].num)

sma[j].sumsales=sma[j].sumsales+sal[j].funsales();

}

sma[i].salary=basepay+sma[i].sumsales*commrate;

}

}

void Salesmanager::print()

{

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

{

相关文档
最新文档