设计雇员Employee类,包含雇员的情况,工号、姓名、工资等级(每月工资数,整型数值)、受雇时间(年、月、日)。编写程序测试Employee类。要求输入任意员工工号,及当前日期(年、月,此日期应晚于受雇时间),输出该员工姓名接应得到的工资总额,中间用空格隔开。
已知当前所有员工信息如下:
1,"wang",5000,2000,10,23
2,"liu",4500,2008,1,20
3,"huo",3800,2003,7,3
4,"ma",5300,2015,4,10
5,"meng",6000,2016,3,16
输入:5 2016 5
输出:meng 12000
#include <iostream>
#include<string>
using namespace std;
class employee{
private:int id; string name; int salary; int year; int month; int day;
public:employee(int i, string n, int s, int y, int m, int d)
{
id = i; name = n; salary = s; year = y; month = m; day = d;
}
void show(int y,int m)
{
cout << name<<" "<<(y-year)*12*salary+(m-month)*salary;
}
};
int main()
{
employee a[5] = {
employee(1, "wang", 5000, 2000, 10, 23),
employee(2, "liu", 4500, 2008, 1, 20),
employee(3, "huo", 3800, 2003, 7, 3),
employee(4, "ma", 5300, 2015, 4, 10),
employee(5, "meng", 6000, 2016, 3, 16) };
int n, y, m;
cin >> n >> y >> m;
a[n-1].show(y, m);
}