计算个人所得税
假设个人所得税为:税率×(工资-1600)。请编写程序计算应缴的所得税。其中税率定义为:
当工资不超过 1600 时,税率为 0;
当工资在区间 (1600, 2500] 时,税率为 5%;
当工资在区间 (2500, 3500] 时,税率为 10%;
当工资在区间 (3500, 4500] 时,税率为 15%;
当工资超过 4500 时,税率为 20%。
输入输出示例:
示例 1:
Your income is:1600
You should tax 0.00 Yuan
示例 2:
Your income is:1601
You should tax 0.05 Yuan
示例 3
Your income is:3000
You should tax 140.00Yuan
示例 4:
Your income is:4000
You should tax 360.00 Yuan
示例 5:
Your income is:5000
You should tax 680.00 Yuan
#include<stdio.h>
int main(void)
{
double income, rate,tax;
//输入收入
printf("Please input your income:");
scanf("%lf", &income);
//根据收入多少判断税率大小
if (income < 0) {
printf("Income can't be less than 0!\n");
}
else if (income <= 1600) {
rate = 0;
}
else if (income <= 2500) {
rate = 0.05;
}
else if (income <= 3500) {
rate = 0.1;
}
else if(income<=4500){
rate = 0.15;
}
else {
rate = 0.2;
}
//计算应缴税额
tax = (income - 1600) * rate;
printf("\nYour income is %.2f\n", income);
printf("You should tax %.2f Yuan\n", tax);
return 0;
}