C语言经典100例 - 002

企业发放的奖金根据利润提成.利润(I)低于或等于10万元时,奖金可提10%;利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可可提成7.5%;20万到40万之间时,高于20万元的部分,可提成5%;40万到60万之间时高于40万元的部分,可提成3%;60万到100万之间时,高于60万元的部分,可提成1.5%,高于100万元时,超过100万元的部分按1%提成,从键盘输入当月利润I,求应发放奖金总数? 

#include <stdio.h>

#define BONUS_10     (100000 * 0.1)
#define BONUS_20     (BONUS_10 + 100000 * 0.075)
#define BONUS_40     (BONUS_20 + 200000 * 0.05)
#define BONUS_60     (BONUS_40 + 200000 * 0.03)
#define BONUS_100    (BONUS_60 + 400000 * 0.015)

int main()
{
    double profit = 0;
    double bonus  = 0;

    // get profit
    printf("Please input profit : ");
    scanf("%lf", &profit);

    // calculate bonus
    if(profit > 1000000)
    {
        bonus = (profit - 1000000) * 0.01 + BONUS_100;
    }
    else if(profit > 600000)
    {
        bonus = (profit - 600000) * 0.015 + BONUS_60;
    }
    else if(profit > 400000)
    {
        bonus = (profit - 400000) * 0.03 + BONUS_40;
    }
    else if(profit > 200000)
    {
        bonus = (profit - 200000) * 0.05 + BONUS_20;
    }
    else if(profit > 100000)
    {
        bonus = (profit - 100000) * 0.075 + BONUS_10;
    }
    else
    {
        bonus = profit * 0.1;
    }

    // display bonus
    printf("Your bonus is : %lf\n", bonus);
    return 0;
}






评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值