12 program [12] to calculate bonuses
Topic: Enterprise commission bonuses based on profits. When profit (I) is less than or equal to 10 million, 10% of the prize can be mentioned; when profit than 10 million, less than 20 million, 10 million commission portion is less than 10%, higher than 100,000 yuan part, 7.5% cocoa commission; is between 200,000 to 400,000, more than 20 million portion may commission 5%; more than 40 million portion is between 400,000 to 600,000, may be 3% commission ; is between from 600,000 to 1,000,000, more than 60 million portion may commission 1.5% above 100 million, more than one million yuan portion 1% commission, from the keyboard month profit I, should seek The total number of paid bonuses?
Program Analysis: Please use axes to cut-off, location. The bonus to be defined in Note grow integer defined.
package cskaoyan; public class cskaoyan12 { @org.junit.Test public void count() { java.util.Scanner in = new java.util.Scanner(System.in); double profit = in.nextDouble(); double bonus = 0; double percent1 = 0.1; double percent2 = 0.075; double percent3 = 0.05; double percent4 = 0.03; double percent5 = 0.015; double percent6 = 0.01; if (profit <= 100000) { bonus = profit * percent1; } else if (profit <= 200000) { bonus = 100000 * percent1 + (profit - 100000) * percent2; } else if (profit <= 400000) { bonus = 100000 * percent1 + (200000 - 100000) * percent2 + (profit - 200000) * percent3; } else if (profit <= 600000) { bonus = 100000 * percent1 + (200000 - 100000) * percent2 + (400000 - 200000) * percent3 + (profit - 400000) * percent4; } else if (profit <= 1000000) { bonus = 100000 * percent1 + (200000 - 100000) * percent2 + (400000 - 200000) * percent3 + (600000 - 400000) * percent4 + (profit - 600000) * percent5; } else { bonus = 100000 * percent1 + (200000 - 100000) * percent2 + (400000 - 200000) * percent3 + (600000 - 400000) * percent4 + (1000000 - 600000) * percent5 + (profit - 1000000) * percent6; } System.out.println(bonus); in.close(); } }