Question: The bonus paid by an enterprise is based on the profit.
If the profit is lower than or equal to 0.1 million yuan, the bonus can be increased by 10%;
If the profit is higher than 0.1 million RMB, if the profit is lower than 0.2 million RMB, the Commission for the portion lower than 0.1 million RMB is 10%. If the profit is higher than 0.1 million RMB, the Commission is 7.5%;
The amount between 0.2 million and 0.4 million is higher than 0.2 million RMB, which can be increased to 5%;
The amount between 0.4 million and 0.6 million is higher than that of 0.4 million yuan, which can be increased to 3%;
The amount between 0.6 million and 1 million is higher than 0.6 million RMB, which can be increased to 1.5%;
When the price is 1 million yuan, the percentage of the price exceeding 1 million Yuan is 1% yuan. input the profit for the current month from the keyboard, and ask for the total number of bonuses to be paid?
Program Analysis: Use the number axis to split and locate. Note that the bonus should be defined as an integer or a long integer.
#include "stdio.h"int main() {int profit;printf("Please input the profit number and kick the Enter: \n");scanf("%d", &profit);int bonus = CountBonus(profit);printf("profit: %d, bonus: %d\n", profit, bonus);return 0;}int CountBonus(int profit) {int flag, bonus = 0, bonus0, bonus1, bonus2, bonus4, bonus6, bonus10;flag = profit/100000;bonus1 = bonus + 100000 * 0.1;bonus2 = bonus1 + 100000 * 0.75;bonus4 = bonus2 + 200000 * 0.5;bonus6 = bonus4 + 200000 * 0.3;bonus10= bonus6 + 200000 * 0.15;switch(flag) {case 0 : bonus = bonus1;break;case 1 : bonus = bonus1 + (profit - 100000) * 0.75;break;case 2 :case 3 :bonus = bonus2 + (profit - 200000) * 0.5;break;case 4 :case 5 : bonus = bonus4 + (profit - 400000) * 0.3;break;case 6 : case 7 : case 8 : case 9 :bonus = bonus6 + (profit - 600000) * 0.15;break;default: bonus = bonus10 + (profit - 1000000) * 0.1;break;}return bonus;}