C++面向对象程序设计之公司人员工资管理

.编写一个小型公司人员工资管理程序,要求设计合理的基类和派生类,实现工资管理任务。下表是公司经理,兼职人员,销售经理和销售人员当月工资计算方法。
这是工资管理中很简单的程序,在此基础上可以做很多的完善。

人员类别 固定工资/元计时工资(元/时) 月销售总额提成
公司经理 15000无 无
兼职人员 无180 无
销售经理 5000无 1%
销售员 无无 6%

代码如下:

#include <iostream>
#include <string>

using namespace std;

class Person
{
public:
	Person(int f, int h, double c);
	~Person() 
	{
		cout << "析构执行成功!" << endl;
	}
double wage_calculation(int t, float ts);
private:
	int fixed_wage;
	int hourly_wage;
	double commission;
	int hour;
	float Total_Sales;

};

Person::Person(int f, int h, double c)
{
	fixed_wage = f;
	hourly_wage = h;
	commission = c;
}
double Person::wage_calculation(int t, float ts)
{

	double total;
	total = fixed_wage + hourly_wage * t + commission * ts;
	return(total);
}

class Company_manager :public Person
{
public:
	Company_manager(int f, int h, double c) :Person(f, h, c) {}
	

};

class partime_staff :public Person
{
public:
	partime_staff(int f, int h, double c) :Person(f, h, c) {}


};

class Sales_manager :public Person
{
public:
	Sales_manager(int f, int h, double c) :Person(f, h, c) {}


};

class saleperson :public Person
{
public:
	saleperson(int f, int h, double c) :Person(f, h, c) {}
};



int main()
{
	string title;
	int hour;
	float Total_Sales;
	cout << "Please enter the 销售总额:"; cin >> Total_Sales;
	cout << endl;
	cout << "Please choose the 职位:"; cin >> title;
	cout << endl;

	//职位的选择和总额的输入
	if (title == "公司经理")
	{
		Company_manager cm(15000, 0, 0);
		cout << "公司经理本月的工资:" << cm.wage_calculation(0, Total_Sales) << endl;
	}
	else if (title == "兼职人员")
	{
		cout << "Please enter the working hours:";
	    cin >> hour;
		partime_staff ps(0, 180, 0);
		cout << "兼职人员本月的工资:" << ps.wage_calculation(hour, Total_Sales) << endl;

		// 按每小时180元计费,工作了几天,每天几个小时
	}
	else if (title == "销售经理")
	{
		Sales_manager sm(5000, 0, 0.01);
		cout << "销售经理本月的工资:" << sm.wage_calculation(0, Total_Sales) << endl;


	}
	else if (title == "销售员")
	{
		saleperson se(0, 0, 0.06);
		cout << "销售员本月的工资:" << se.wage_calculation(0, Total_Sales) << endl;
	}
	return 0;
}

输出示例如下:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值