实训2 个人所得税计算器
任务描述:编写C程序,根据输入的月收入计算个人所得税及税后收入。
学习目标:掌握顺序结构和选择结构(如if-else)的应用,理解税收计算逻辑。
任务要求:
Ø 按照以下税率表(起征点5000元,超额累进税率)计算;
Ø 输出税前收入、应纳税额、税后收入。
#include <stdio.h>
int main() {
double income, taxable_income, tax, after_tax;
// 输入月收入
printf(“请输入月收入:”);
scanf(“%lf”, &income);
// 计算应纳税所得额(月收入 – 起征点5000元)
taxable_income = income – 5000;
// 根据应纳税所得额区间计算个税
if (taxable_income <= 0) {
tax = 0;
} else if (taxable_income <= 36000) {
tax = taxable_income * 0.03;
} else if (taxable_income <= 144000) {
tax = taxable_income * 0.1 – 2520;
} else if (taxable_income <= 300000) {
tax = taxable_income * 0.2 – 16920;
} else if (taxable_income <= 420000) {
tax = taxable_income * 0.25 – 31920;
} else if (taxable_income <= 660000) {
tax = taxable_income * 0.3 – 52920;
} else if (taxable_income <= 960000) {
tax = taxable_income * 0.35 – 85920;
} else {
tax = taxable_income * 0.45 – 181920;
}
// 计算税后收入
after_tax = income – tax;
// 输出结果
printf(“税前收入:%.2f 元\n”, income);
printf(“应纳税额:%.2f 元\n”, tax);
printf(“税后收入:%.2f 元\n”, after_tax);
return 0;
}

