Example 2 C Exercise
100 cases of classic C language
Title: Corporate bonuses based on profit commission. When profits (I) is less than or equal to $ 100,000, bonus of 10% can be mentioned; when profits exceeding 10 million, less than 20 million, some 10 million less than the 10% commission, higher than 100,000 yuan part of cocoa commission of 7.5%; when between 200,000 to 400,000, more than 20 million parts can be 5% commission; when between 400,000 to 600,000 higher than 400,000 yuan section, you can deduct a percentage of 3% ; when between 600 thousand to 1 million, more than 60 million yuan section, you can deduct a percentage of 1.5%, higher than 100 million, more than 1 million yuan part 1% commission from the keyboard input of the month profit I, should seek Total bonuses paid?
Program Analysis: Please use the number of axes boundaries, location. The growing need to define integer bonus note definition.
Source Code:
#include<stdio.h> int main() { double i; double bonus1,bonus2,bonus4,bonus6,bonus10,bonus; printf("你的净利润是:\n"); scanf("%lf",&i); bonus1=100000*0.1; bonus2=bonus1+100000*0.075; bonus4=bonus2+200000*0.05; bonus6=bonus4+200000*0.03; bonus10=bonus6+400000*0.015; if(i<=100000) { bonus=i*0.1; } else if(i<=200000) { bonus=bonus1+(i-100000)*0.075; } else if(i<=400000) { bonus=bonus2+(i-200000)*0.05; } else if(i<=600000) { bonus=bonus4+(i-400000)*0.03; } else if(i<=1000000) { bonus=bonus6+(i-600000)*0.015; } else if(i>1000000) { bonus=bonus10+(i-1000000)*0.01; } printf("提成为:bonus=%lf",bonus); printf("\n"); }
The above example output is:
你的净利润是: 120000 提成为:bonus=11500.000000