请编写一个个税计算器,c语言 用户输入为应发工资薪金所得扣除五险一金后的金额,输出应缴税款和实发工资,结果保留小数点后两位。当输入数字小于0时,输出“error”。
时间: 2024-03-07 13:51:23 浏览: 89
suodeshui.rar_vb个人所得税
好的,以下是个税计算器的代码,可以满足您的需求:
```c
#include <stdio.h>
int main() {
float salary, tax, afterTax;
printf("请输入应发工资薪金所得扣除五险一金后的金额:");
scanf("%f", &salary);
if(salary < 0) {
printf("error");
return 0;
}
float insurance = salary * 0.08;
float deduction = salary - insurance - 5000;
if(deduction <= 0) {
tax = 0;
} else if(deduction <= 3000) {
tax = deduction * 0.03;
} else if(deduction <= 12000) {
tax = deduction * 0.1 - 210;
} else if(deduction <= 25000) {
tax = deduction * 0.2 - 1410;
} else if(deduction <= 35000) {
tax = deduction * 0.25 - 2660;
} else if(deduction <= 55000) {
tax = deduction * 0.3 - 4410;
} else if(deduction <= 80000) {
tax = deduction * 0.35 - 7160;
} else {
tax = deduction * 0.45 - 15160;
}
afterTax = salary - insurance - tax;
printf("应缴税款为:%.2f,实发工资为:%.2f", tax, afterTax);
return 0;
}
```
程序会首先要求用户输入应发工资薪金所得扣除五险一金后的金额,然后判断输入的金额是否小于0。如果小于0,程序会输出“error”,并结束运行。如果金额大于等于0,程序会计算五险一金和个人所得税,最后输出应缴税款和实发工资。个人所得税的计算采用了中国大陆的税法标准,按照税前收入扣除五险一金和个人起征点后的应纳税所得额计算税款额度。
阅读全文