写一份c语言实现利润提成,用switch
时间: 2023-06-01 22:02:13 浏览: 105
Java基础编程:企业发放的奖金根据利润提成-Java实现
#include <stdio.h>
int main() {
int profit;
double bonus;
printf("请输入利润(万元):");
scanf("%d", &profit);
switch(profit/10) {
case 0:
bonus = profit * 0.1;
break;
case 1:
bonus = 10 * 0.1 + (profit-10) * 0.075;
break;
case 2:
case 3:
bonus = 10 * 0.1 + 10 * 0.075 + (profit-20) * 0.05;
break;
case 4:
case 5:
bonus = 10 * 0.1 + 10 * 0.075 + 20 * 0.05 + (profit-40) * 0.03;
break;
default:
bonus = 10 * 0.1 + 10 * 0.075 + 20 * 0.05 + 20 * 0.03 + (profit-60) * 0.015;
}
printf("应发放奖金为%.2f万元\n", bonus);
return 0;
}
阅读全文