web123456

Java programming questions - Enter the profit I of the month from the keyboard and find the total amount of bonuses to be issued.

import java.util.Scanner; /** * The bonuses issued by the company are based on the commission for profit. If the profit I is less than or equal to RMB 100,000, the bonus can be 10% commission; * When profits are above RMB 100,000 and below RMB 200,000 (100,000 < I ≤ 200,000), * The commission for the part below 100,000 yuan is 10%, and the commission for the part above 100,000 yuan is 7.5%; * When 200 000 < I ≤ 400 000, the part below 200 000 yuan will still be commissioned according to the above method (same below). * The commission of the above RMB 200,000 is 5%; * When 400 000 < I ≤ 600 000 yuan, the commission for those above 400 000 yuan is 3%; * When 600 000 < I ≤ 1 000 000, the commission for the part above 600 000 yuan will be 1.5%; * When I > 1 000 000, the commission for more than 1 000 000 yuan will be charged 1%. * Enter the profit I of the month from the keyboard to find the total amount of bonuses to be issued. */ public class bonus { public static void main(String[] args) { //Create a new object of input Scanner input = new Scanner(System.in); //Input interest rate System.out.println("Please enter interest rate:"); float x = input.nextFloat(); // Calculate the bonus relative to the interval float p1 = (float)(x * 0.1); float p2 = p1 + (float)((x - 100000) * 0.075); float p3 = p2 + (float)((x - 200000) * 0.05); float p4 = p3 + (float)((x - 400000) * 0.03); float p5 = p4 + (float)((x - 600000) * 0.015); float p6 = p5 + (float)((x - 1000000) * 0.01); //Judge the interest rate corresponding to the interest rate and output the bonus if(x <= 100000) System.out.println("The bonus is:" + p1); else if(x > 100000 && x <= 200000) System.out.println("The bonus is:" + p2); else if(x > 200000 && x <= 400000) System.out.println("The bonus is:" + p3); else if(x > 400000 && x <= 600000) System.out.println("The bonus is:" + p4); else if(x > 600000 && x <= 1000000) System.out.println("The bonus is:" + p5); else if(x > 1000000) System.out.println("The bonus is:" + p6); } }