codeup之奖金计算

36 篇文章 0 订阅

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

solution1

#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;
} 

solution2

#include <stdio.h>
int main(){
	double profit, bonus;
	scanf("%lf", &profit);
	if(profit <= 100000){
		bonus = 0.1 * profit;
	}
	else if(profit <= 200000){
		bonus = 10000 + 0.075 * (profit - 100000);
	}
	else if(profit <= 400000){
		bonus = 17500 + 0.05 * (profit - 200000);
	}
	else if(profit <= 600000){
		bonus = 27500 + 0.03 * (profit - 400000);
	}
	else if(profit <= 1000000){
		bonus = 33500 + 0.015 * (profit - 600000);
	}
	else{
		bonus = 39500 + 0.01 * (profit - 1000000);
	}
	printf("%.2f", bonus);
	return 0;
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值