输入一个职工的月薪salary,输出应交的个人所得税tax。 tax+=+rate+*+(salary-850) 当+salary+<=+850+时,rate+=+0%; 当+850+<+salar
时间: 2023-11-15 19:07:19 浏览: 184
据提供的引用,输入一个职工的月薪salary,输出应交的个人所得税tax。根据不同的salary范围,税率rate也不同,可以使用if语句进行判断。最后计算出税金tax并保留两位小数输出即可。
```c
#include <stdio.h>
int main() {
double salary, rate, tax;
scanf("%lf", &salary);
if (salary <= 850) {
rate = 0.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("tax=%.2lf", tax);
return 0;
}
```
相关问题
用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%
好的,以下是用 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 位小数)。 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;
}
```
阅读全文