c++实训(7)

你们一直让我更,我就更一下吧,我也不知道以前写过没,你们需要我就更啦!多多支持,多多点赞。
例1.工资类的计算
生成一个GZ类表示工资,用静态成员表示个人所得税占工资比例。类的每个成员包含一个私有数据成员money,表示当月工资。提供一个calSDS()成员函数,计算个人应交所得税,并从money中扣除。
实例化三个不同的GZ对象people1、people2和people3,工资分别为12000 、56000 和480000。分别计算三人实际应发的工资数并打印结果。
(1)用静态数据成员表示个人所得税占工资的比例;
(2)编写计算个人应交所得税成员函数calSDS();
(3)生成GZ类的三个对象;
(4)对三个对象分别计算实际应发的工资数;
(3)显示程序结果;
代码如下:

#include<iostream>
using namespace std;
class GZ
{
   
private:
	float money;
public:
	void calSDS();
	float static SDS1;
	float static SDS2;
	float static SDS3;
	float static SDS4;
	float static SDS5;
	float static SDS6;
	float static SDS7;
	float static SDS8;
	float static SDS9;  //9个静态数据成员
	GZ(float x);
};
float GZ::SDS1=0.05;  //静态数据成员
float GZ::SDS2=0.1;
float GZ::SDS3=0.15;
float GZ::SDS4=0.2;
float GZ::SDS5=0.25;
float GZ::SDS6=0.3;
float GZ::SDS7=0.35;
float GZ::SDS8=0.4;
float GZ::SDS9=0.45;
GZ::GZ(float x)  // 设置工资
{
   
money=x;
}
void GZ::calSDS()  //成员函数  计算扣除个人所得税的实际工资数
{
   
float x=0.0;
cout
  • 12
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 9
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值