Java basic arithmetic questions (12): Enterprise commission bonuses based on profits. When profit (I) is less than or equal to 10 million, 10% bonus may be mentioned;

View all 50 basic arithmetic questions, see:

Java basic algorithm of 50 questions

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 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 bonuses?

package Demo12Bonus;
import java.util.Scanner;
public class Bonus {
    /**
     * 企业发放的奖金根据利润提成。利润(I)低于或等于10万元时,奖金可提10%;利润高于10万元,低于20万
     * 元时,低于10万元的部分按10%提成,高于10万元的部分,可可提成7.5%;20万到40万之间时,高于20万元的部
     * 分,可提成5%;40万到60万之间时高于40万元的部分,可提成3%;60万到100万之间时,高于60万元的部分,可提成1.5%,
     * 高于100万元时,超过100万元的部分按1%提成,从键盘输入当月利润I,求应发放奖金?
     */
    /*
    分析:I<=10     --> bonus=I*10%
         10<I<=20  --> bonus=10*10%+(I-10)*7.5%
         20<I<=40  --> bonus=10*10%+10*7.5%+(I-20)*5%
         40<I<=60  --> bonus=10*10%+10*7.5%+20*5%+(I-40)*3%
         60<I<=100 --> bonus=10*10%+10*7.5%+20*5%+20*3%+(I-60)*1.5%
         100<I     --> bonus=10*10%+10*7.5%+20*5%+20*3%+40*1.5%+(I-100)*1%
     */
    public static void main(String[] args) {
        // 获取用户输入的利润
        System.out.println("请输入当月的利润:");
        Scanner sc = new Scanner(System.in);
        double I = sc.nextInt();
        // 定义一个变量来盛奖金
        double bonus = 0;
        // 根据我们的分析,用if...else if语句来实现结果判断,并完成计算
        if(I<=10){
            bonus=I*0.1;
        }else if(10<I && I <=20){
            bonus=10*0.1+(I-10)*0.075;
        }else if(20<I && I<=40){
            bonus=10*0.1+10*0.075+(I-20)*0.05;
        }else if(40<I && I <=60){
            bonus=10*0.1+10*0.075+20*0.05+(I-40)*0.03;
        }else if(60<I && I <=100){
            bonus=10*0.1+10*0.075+20*0.05+20*0.03+(I-60)*0.015;
        }else if(I >100){
            bonus=10*0.1+10*0.075+20*0.05+20*0.03+40*0.015+(I-100)*0.01;
        }
        System.out.println("根据您的输入,当月应得的奖金应为:"+bonus+"万元。");
    }
}
Published 22 original articles · won praise 1 · views 1417

Guess you like

Origin blog.csdn.net/weixin_44803446/article/details/105354833