#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
double Bonus(int i)
{
int a = 0;
double money = 0;
int rem = 0;
//看有几个10万
//注意这里是向下取整,待会儿还要把余数进行计算
a = i / 100000;
rem = i % 100000;
//把不同阶段的10万进行不同的奖金制度(最低档10万及以下,最高档100万以上)
//因为金额是向下兼容的(20万必然包含10万)
//所以我们中间不设置break,直接让它一直累积到底
switch(a)
{
case 10:
money += 100000 * 0.015;
case 9:
money += 100000 * 0.015;
case 8:
money += 100000 * 0.015;
case 7:
money += 100000 * 0.015;
case 6:
if (a >= 6)
{
money += rem * 0.015;
}
money += 100000 * 0.03;
case 5:
money += 100000 * 0.03;
case 4:
if (a >= 4 && a < 6)
{
money += rem * 0.03;
}
money += 100000 * 0.05;
case 3:
money += 100000 * 0.05;
case 2:
if (a >= 2 && a < 4)
{
money += rem * 0.05;
}
money += 100000 * 0.075;
case 1:
if (a >= 1 && a < 2)
{
money += rem * 0.075;
}
money += 100000 * 0.1;
break;
//利润不够10万时
default:
if (a < 1)
{
money += rem * 0.1;
}
break;
}
return money;
}
int main()
{
int i = 0;
double money = 0;
printf("请输入本月的利润,单位为元:");
//输入
scanf("%d", &i);
//计算奖金
money = Bonus(i);
//输出
printf("本月应发奖金为%.2lf元\n", money);
return 0;
}