题目描述
企业发放的奖金根据利润提成。利润低于或等于100000元的,奖金可提10%;
利润高于100000元,低于200000元(100000<I≤200000)时,低于100000元的部分按10%提成,高于100000元的部分,可提成 7.5%;
200000<I≤400000时,低于200000元部分仍按上述办法提成,(下同),高于200000元的部分按5%提成;
400000<I≤600000元时,高于400000元的部分按3%提成;
600000<I≤1000000时,高于600000元的部分按1.5%提成;
I>1000000时,超过1000000元的部分按1%提成。从键盘输入当月利润I,求应发奖金总数。
输入
一个整数,当月利润。
输出
一个整数,奖金。
样例输入
900
样例输出
90
C语言代码
#include <stdio.h>
int main(int argc, const char *argv[])
{
//定义一个无符号整型变量并初始化为0
unsigned int Profit = 0;
//输入数据
scanf("%u",&Profit);
//如果输入的数据不符合条件,则直接退出程序
if(0 > Profit){
return 0;
}
//采用if……else语句判断
unsigned int Bonus = 0;
if(Profit <= 100000){
Bonus += Profit * 0.1;
printf("%d\n", Bonus);
}else if(Profit <= 200000){
Bonus += 100000 * 0.1;
Bonus += (Profit - 100000) * 0.075;
printf("%d\n", Bonus);
}else if(Profit <= 400000){
Bonus += 100000 * 0.1;
Bonus += 100000 * 0.075;
Bonus += (Profit - 200000) * 0.05;
printf("%d\n", Bonus);
}else if(Profit <= 600000){
Bonus += 100000 * 0.1;
Bonus += 100000 * 0.075;
Bonus += 200000 * 0.05;
Bonus += (Profit - 400000) * 0.03;
printf("%d\n", Bonus);
}else if(Profit <= 1000000){
Bonus += 100000 * 0.1;
Bonus += 100000 * 0.075;
Bonus += 200000 * 0.05;
Bonus += 200000 * 0.03;
Bonus += (Profit - 600000) * 0.015;
printf("%d\n", Bonus);
}else{
Bonus += 100000 * 0.1;
Bonus += 100000 * 0.075;
Bonus += 200000 * 0.05;
Bonus += 200000 * 0.03;
Bonus += 400000 * 0.015;
Bonus += (Profit - 1000000) * 0.01;
printf("%d\n", Bonus);
}
return 0;
}