2.1个人所得税问题
4.
#include <iostream>
#include <cstring>
using namespace std;
class Incomec{ // 建立一个incomec类
private:
float income;
static double wage; // wage数据成员,表示职工工资;
static double taxrate; // taxrate数据成员,表示税率;
public:
incomec();
void setWage(double m); // setWage(double m)成员函数,设置工资值;
static double getTaxrat(); // getTaxrat()成员函数,计算税率;
static double calIncome(); // calIncome()成员函数,计算职工的实际收入;
};
Incomec::incomec(){
}
void Incomec::setWage(double salary){
wage = salary;
}
double Incomec::calIncome(){
return wage - (wage - 2000) * taxrate;
}
// 超过部分在2000元以下,征收5%;5000元以下,征税10%;10000元以下,征税15%;10000元以上,征税20%。
double Incomec::getTaxrat(){
if (wage <= 3500){
taxrate = 0;
} else if (wage < 8000){
taxrate = 0.1;
} else if (wage < 12500){
taxrate = 0.12;
} else if (wage <= 38500){
taxrate = 0.25;
}else if(wage<=58500){
taxrate =0.3;
}else if(wage<=83500){
taxrate=0.35;
}else {
taxrate = 0.45;
}
return taxrate;
}
double Incomec::taxrate = 0;
double Incomec::wage = 0;
int main(){ // 在主函数中,实例化不同的incomec类对象,并计算它们的实际收入
Incomec *incomec = new Incomec();
double salary;
cin >> salary;
incomec -> setWage(salary);
incomec -> getTaxrat();
cout << incomec -> calIncome() << endl;
delete incomec;
return 0;
}