用c语言编写程序输入一个职工的月薪 salary,输出应交的个人所得税 tax(保留 2 位小数)。 计算公式:tax = rate * (salary - 850) 当 salary ≤850 时,rate = 0 当 850 < salary ≤ 1350 时,rate = 5% 当 1350 < salary≤ 2850 时,rate = 10% 当 2850 < salary ≤ 5850 时,rate = 15% 当 5850 < salary 时,rate = 20%
时间: 2024-03-31 17:34:32 浏览: 201
好的,以下是用 C 语言编写的程序,可以输入职工的月薪 salary,输出应交的个人所得税 tax。
```c
#include <stdio.h>
int main() {
float salary, tax, rate;
printf("请输入职工的月薪:");
scanf("%f", &salary);
if (salary <= 850) {
rate = 0;
} else if (salary <= 1350) {
rate = 0.05;
} else if (salary <= 2850) {
rate = 0.1;
} else if (salary <= 5850) {
rate = 0.15;
} else {
rate = 0.2;
}
tax = rate * (salary - 850);
printf("应交个人所得税为:%.2f\n", tax);
return 0;
}
```
程序运行时,会提示您输入职工的月薪,然后根据输入的月薪计算个人所得税并输出。注意,输出时保留 2 位小数。
相关问题
用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。
#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位小数。
C语言代码,输入一个职工的月薪 salary,输出应交的个人所得税tax(保留2 位小数)。 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;
```c
#include <stdio.h>
int main() {
float salary, tax, rate, deduction;
scanf("%f", &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 = rate * (salary - 3500) - deduction;
printf("%.2f", tax);
return 0;
}
```
阅读全文