用C语言编写程序,输入月薪salary,输出应交的个人所得税tax(保留2位小数)。按照2011年开始实行的新的个人所得税法,计算公式为: tax=rate*(salary - 3500)- deduction 当salary ≤ 3500时,rate = 0、deduction = 0; 当3500 < salary ≤ 5000时,rate = 3%、deduction = 0; 当5000 < salary ≤ 8000时,rate = 10%、deduction = 105; 当8000 < salary ≤ 12500时,rate = 20%、deduction = 555; 当12500 < salary ≤ 38500时,rate = 25%、deduction = 1005; 当38500 < salary ≤ 58500时,rate = 30%、deduction = 2755; 当58500 < salary ≤ 83500时,rate = 35%、deduction = 5505; 当83500 < salary时,rate = 45%、deduction = 13505。
时间: 2023-02-11 16:06:26 浏览: 197
#include <stdio.h>
int main() {
double salary, rate, tax, deduction;
printf("请输入月薪: ");
scanf("%lf", &salary);
if (salary <= 3500) {
rate = 0;
deduction = 0;
} else if (salary <= 5000) {
rate = 0.03;
deduction = 0;
} else if (salary <= 8000) {
rate = 0.1;
deduction = 105;
} else if (salary <= 12500) {
rate = 0.2;
deduction = 555;
} else if (salary <= 38500) {
rate = 0.25;
deduction = 1005;
} else if (salary <= 58500) {
rate = 0.3;
deduction = 2755;
} else if (salary <= 83500) {
rate = 0.35;
deduction = 5505;
} else {
rate = 0.45;
deduction = 13505;
}
tax = (salary - 3500) * rate - deduction;
printf("应交个人所得税为: %.2lf\n", tax);
return 0;
}
程序会提示用户输入月薪, 然后根据输入的月薪使用if-else语句计算出应交的个人所得税。
最后通过printf输出,保留2位小数。
阅读全文