求助。琢磨了好久
# include<stdio.h>int main(void)
{
int deduction;
double tax,salary,rate;
printf("Enter salary:");
scanf("%lf",&salary);
if(salary<=3500)
{
deduction=0,rate=0.00;
tax=rate*(salary-3500)-deduction;
}
else
if(salary<=5000)
deduction=0,rate=0.03;
else
if(salary<=8000)
deduction=105,rate=0.10;
else
if(salary<=12500)
deduction=555,rate=0.20;
else
if(salary<=38500)
deduction=1005,rate=0.25;
else
if(salary<=58500)
deduction=2775,rate=0.30;
else
if(salary>58500)
deduction=13505,rate=0.45;
tax=rate*(salary-3500)-deduction;
printf("tax=%.2f",tax);
return 0;
}
输入月薪salary,输出应交的个人所得税tax(保留2位小数)。按照2011年开始实行的新的个人所得税法,计算公式为: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=2775
当83500<salary时,rate=45%、deduction=13505
这是题目,其他都解决了,但是输入3500以下的,比如200,输出结果为-0.00.应该是0.00,请问这是怎么回事?