codeup之奖金计算

codeup c2奖金计算

Description

某企业发放的奖金根据利润提成。利润I低于或等于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,求应发奖金数,奖金精确到分。

要求用if语句实现。

Input

企业利润,小数,双精度double类型

Output

应发奖金数,保留2位小数,末尾换行。

Sample Input Copy

1050

Sample Output Copy

105.00

solution

#include <stdio.h>
#include <math.h>
int main(){
	double profit, bonus;
	scanf("%lf", &profit);
	if(profit <= 100000){//奖金<10^5 
		bonus = profit * 0.1;
	}
	else{
		bonus = 10000;
		if(profit <= 200000){//奖金10^5~2*10^5 
			bonus += (profit - 100000) * 0.075;
		}
		else{
			bonus += 7500;
			if(profit <= 400000){//奖金2*10^5~4*10^5
				bonus += (profit - 200000) * 0.05;
			}
			else{
				bonus += 5000;
				if(profit <= 600000){//奖金4*10^5~6*10^5
					bonus += (profit - 400000) * 0.03;
				}
				else{
					bonus += 3000;
					if(profit <= 1000000){
						bonus += (profit - 600000) * 0.015;
					}
					else{
						bonus += 6000 + (profit - 1000000) * 0.01;
					}
				}
			}
		}
	}
	printf("%.2f\n", bonus);
	return 0;
} 
posted @ 2021-12-31 12:32  Moliay  阅读(17)  评论(0编辑  收藏  举报