Tan Haoqiang's edition of "C Program Design" (second edition) P105 5.8 bonuses awarded by enterprises are based on profit percentage.
Profit I is less than or equal to 100,000 yuan, bonuses can be 10%;200000<i<=400000, below 200,000 far lower part of the above method of Commission (hereinafter). More than 200,000 yuan of the part of 5% commission; When 400000<i<=600000, more than 400,000 yuan of the part by 3% commission; When 600000<i<=1000000, higher than 600,000 yuan part by 1.5% Commission; I>1000000, More than 1 million yuan of the part by 1% Commission. Enter the monthly profit from the keyboard I, the total number of bonuses should be issued.
#include <stdio.h>
int main ()
{
float i,jj,jj10w,jj20w,jj40w,jj60w,jj100w;
printf ("Please enter profit:");
scanf ("%f", &i);
Fflush (stdin);
jj10w=100000*0.1;
jj20w=jj10w+100000*0.075;
jj40w=jj20w+200000*0.05;
jj60w=jj40w+200000*0.03;
jj100w=jj60w+400000*0.015;
int DANGCI;
dangci=i/100000;
Switch (DANGCI)
{case
0:jj=i*0.01;break;
Case 1:jj=jj10w+ (I-100000) *0.075;break;
Case 2: Case
3:jj=jj20w+ (I-200000) *0.05;break;
Case 4: Case
5: Case
6:jj=jj40w+ (I-400000) *0.03;break;
Case 7: Case
8: Case
9:jj=jj60w+ (I-600000) *0.015;break;
Case 10:jj=jj100w+ (I-1000000) *0.001;break;
}
printf ("Bonus:%.2f\n", JJ);
return 0;
}
is much clearer than if statement version.