源码简介: |
1.某单位的职工工资包括基本工资Wage,岗位津贴Subsidy,房租Rent,水费WaterFee,电费ElecFee。设计是实现工资管理的类Salary,该类的形式如下:Class Salary{Double Wage,Subsidy,Rent,WaterFee,ElecFee Pulic: Salary(……){初始化工资数据的各分项} Salary(){初始化工资数据的各分项数据为0} Void setXX(double f){xx=f } Double getXX(){return xx } Double RealSalary() //计算实发工资} 其中,成员函数setXX用于设置工资的各分项数据,成员函数getXX用于获取工资各分项数据,xx代表Wage,Subsidy等数据成员。实发工资=Wage+Subsidy-Rent-WaterFee-ElecFee编写程序完善该类的设计,并写出测试该类成员函数的主函数main。2.设计工人类Worker,它具有姓名name,年龄age,工作部门Dept,工资salary等数据成员。其中,Salary使用上题上定义的类。完成Worker类的设计,并统计工人的人数,编写测试程序进行测试。-1 a unit of wages including basic wage Wage, job subsidies Subsidy, rent Rent, water WaterFee, electricity ElecFee. Design is to achieve the payroll of the class Salary, such forms as follows: Class Salary { Double Wage, Subsidy, Rent, WaterFee, ElecFee Pulic: Salary (... ...) {initialize the wage data of the sub-} Salary () {initialize the wage data of the sub-data to 0} Void setXX (double f) {xx = f } Double getXX () {return xx } Double RealSalary ()// calculate the real wages } Among them, the member function used to set wages setXX the sub-data, member functions getXX used to obtain the wage data in the sub, xx on behalf of Wage, Subsidy and other data members. Real wages = Wage Subsidy-Rent-WaterFee-ElecFee Improve the design of such programming, and testing of such a member function to write the main function main. (2) design of the workers class Worker, it has the name name, age, age, department Dept, salary wages and other data members.
|