我编的一个奖金取得程序,为什么不论怎么输入都是没有奖金呢?
#include"stdio.h"#include"math.h"
void main()
{
double profit,bonus;
scanf("%f",&profit);
if(profit<=0)
{
printf("今年没有奖金!\n");
}
else
{
if(profit<=10)
{
bonus=profit*10.0/100;
}
else if(profit<=20)
{
bonus=10*10.0/100+(profit-10)*7.5/100;
}
else if(profit<=40)
{
bonus=10*10.0/100+10*7.5/100+(profit-20)*5.0/100;
}
else if(profit<=60)
{
bonus=10*10.0/100+10*7.5/100+20*5.0/100+(profit-40)*3.0/100;
}
else if(profit<=100)
{
bonus=10*10.0/100+10*7.5/100+20*5.0/100+20*3.0/100+(profit-60)*1.5/100;
}
else
{
bonus=10*10.0/100+10*7.5/100+20*5.0/100+20*3.0/100+40*1.5/100+(profit-100)*1.0/100;
}
printf("今年的奖金是%g\n",bonus);
}
}