假设计算个人所得税的规定为:月工资3500元以下,不用交,超过3500元至5000元部分,纳税比率为3%;超过5000元至9500元部分,纳税比率为10%;超过9500元部分,纳税比率为20%;编程计算个人所得税。
有谁能帮我修改一下程序,当输入8000时可以运行出结果吗?谢谢。
#include<stdio.h>
int main()
{
float income,tax;
printf("inpute the income:\n");
scanf("%f",&income);
if(income<0)
{
printf("input error!");
}
else if(income<=3500)
{
tax=0;
printf("the tax is:%.2f",tax);
}
else if(income<=5000)
{
tax=(income-3500)(3/100);
printf("the tax is:%.2f",tax);
}
else if(income<=9500)
{
tax=1500(3/100)+(income-5000)(1/10);
printf("the tax is:%.2f",tax);
}
else
{
tax=1500(3/100)+4500*(1/10)+(income-9500)*(1/5);
printf("the tax is:%.2f",tax);
}
return 0;
}
修改如下,供参考:
#include <stdio.h>
int main()
{
float income, tax;
printf("inpute the income:\n");
scanf("%f", &income);
if (income < 0)
{
printf("input error!");
}
else if (income <= 3500)
{
tax = 0;
printf("the tax is:%.2f", tax);
}
else if (income > 3500 && income <= 5000)
{
tax = (income - 3500)*(3.0 / 100);
printf("the tax is:%.2f", tax);
}
else if (income > 5000 && income <= 9500)
{
tax = 1500 *(3.0 / 100) + (income - 5000)*(1.0 / 10);
printf("the tax is:%.2f", tax);
}
else
{
tax = 1500*(3.0 / 100) + 4500 * (1.0 / 10) + (income - 9500) * (1.0 / 5);
printf("the tax is:%.2f", tax);
}
return 0;
}
你为什么把乘号省略了