Tulis program pengiraan cukai pendapatan peribadi
Kaedah pengiraan ialah: 1. Tiada cukai untuk 5,000;
0.10+200000.15+30000.20;
#include <iostream>
using namespace std;
double shuishou(double); //函数原型
double basePay; //税前工资
const double fir_income_tax = 0.10; //第一档所得税率
const double sec_income_tax = 0.15;//第二档所得税率
const double tr_income_tax = 0.20;//第三档所得税率
const int base = 5000; //开始计算所得税下限
const int sec = 15000; //所得税第二档计算上限
const int tre = 35000; //所得税最高档计算下限
double income_tax; //实际所得税
int main()
{
cout << "请输入您的工资\n";
while (cin >> basePay) //判断用户输入是否有效
{
if (basePay == 0 || basePay < 0) //如果用户输入0或小于零程序退出
break;
else
{
double show;
show = shuishou(basePay);
cout << "您应交个人所得税为:"<<show << "元\n";
cout << "请输入您的工资!\n";
cin >> basePay;
}
}
return 0;
}
double shuishou(double basePay)
{
if (basePay <= base) //如果用户工资小于等于5000,则不交所得税
return 0;
else if (basePay > base&&basePay < sec)
{
//用户工资进入第一档税收计算范围
income_tax = (basePay - base)*fir_income_tax;
return income_tax;
}
else if (basePay > sec&&basePay < tre)
{
//用户工资进入第二档税收计算范围
income_tax = (basePay - sec)*sec_income_tax + (sec - base)*0.10;
return income_tax;
}
else if (basePay > tre)
{
//用户工资进第三档税收计算范围
income_tax = (basePay - tre)*tr_income_tax + (tre - sec)*0.15 + (sec - base)*0.10;
return income_tax;
}
return 0;
}
Alih keluar cin >>
Terima kasih banyak-banyak! Saya akan cuba