奖金提成(switch语句)
文章目录
- 题目描述
- 要求:用switch实现。
- 输入
- 输出
- 代码
题目描述
利润≤10000元时,奖金可提成10%;
10000<利润≤20000时,低于10000元的部分按10%提成,高于10000元的部分,可提成7.5%;
20000<利润≤40000时,低于20000元部分仍按上述办法提成,(下同),高于20000元的部分按5%提成;
40000<利润≤60000元时,高于40000元的部分按3%提成;
60000<利润≤100000时,高于60000元的部分按1.5%提成;
利润>100000时,超过100000元的部分按1%提成。
要求:用switch实现。
输入
输入一个int型数据表示利润
输出
输出应得的奖金(注意奖金是整数,不是小数)
代码
#include<stdio.h>
int main(){int profit,a;scanf("%d",&profit);switch(profit/10000){case 0:a=profit*0.1;printf("%d",a);break;case 1:a=10000*0.1+(profit-10000)*0.075;printf("%d",a);break;case 2:case 3:a=1750+(profit-20000)*0.05;printf("%d",a);break;case 4:case 5:a=2750+(profit-40000)*0.03;printf("%d",a);break;case 6:case 7:case 8:case 9:a=3350+(profit-60000)*0.015;printf("%d",a);break;case 10:default:a=3950+(profit-100000)*0.01;printf("%d",a);break;}return 0;
}