一道c题目
题目:企业发放的奖金根据利润提成。利润(I)低于或等于10万元时,奖金可提10%;利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可可提 成7.5%;20万到40万之间时,高于20万元的部分,可提成5%;40万到60万之间时高于40万元的部分,可提成3%;60万到100万之间时,高于60万元的部分,可提成1.5%,高于100万元时,超过100万元的部分按1%提成,从键盘输入当月利润I,求应发放奖金总数?
三天没人发答案,我就公布答案。{:5_109:} #include<stdio.h>
int main()
{
double bonuslist[] = {10000,17500,27500,33500,39500};
double profits = 150000.0;
double bonus = 0.0;
printf("Enter profits:");
scanf("%lf",&profits);
if(profits >0.0)
{
if(profits <= 100000)bonus = profits * 0.1;
else if(profits > 100000 && profits <=200000)
bonus = bonuslist + (profits - 100000) * 0.075;
else if(profits > 200000 && profits <=400000)
bonus = bonuslist + (profits - 200000) * 0.05;
else if(profits > 400000 && profits <=600000)
bonus = bonuslist + (profits - 400000) * 0.03;
else if(profits > 600000 && profits <=1000000)
bonus = bonuslist + (profits - 600000) * 0.015;
else if(profits >= 1000000)
bonus = bonuslist + (profits - 1000000) * 0.01;
printf("%f\n",bonus);
}
else
printf("0");
return 0;
}
页:
[1]