题目:企业发放的奖金根据利润提成。
利润(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,求应发放奖金总数?

程序分析:请利用数轴来分界,定位。注意定义时需把奖金定义成长整型。

public class 第十二题根据提成发放奖金 {
    public static void main(String[] args) {
        System.out.print("请输入利润金额:");
        Scanner in = new Scanner(System.in);
        double bonus = 0; //奖金
        double profit = in.nextDouble(); //利润
        in.close();
        if(profit<=0) {
            System.out.println("输入错误");
        }
        else if(profit > 0 && profit <= 10) { //小于10万
            bonus = profit * 0.1;
        } else if(profit > 10 && profit <20) { //10-20万
            bonus =  (profit-10) * 0.075 + 1;
        } else if(profit >=20 && profit <40) { //20-40万
            bonus =  (profit-20)*0.05 + 1.75;
        } else if(profit >=40 && profit < 60) { //40-60万
            bonus =  (profit-40)*0.03 + 2.75;
        } else if(profit >=60 && profit < 100) { //60-100万
            bonus =  (profit-60)*0.015 + 3.35;
        } else {
            bonus =  (profit-100)*0.001 + 3.95; //大于100万
        }
        System.out.println("奖金为:"+ (bonus*10000) +"元");
    }
}

 

相关文章:

  • 2021-09-13
  • 2021-06-07
  • 2022-01-04
  • 2021-05-22
  • 2021-11-16
  • 2022-02-19
  • 2022-01-02
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-06
  • 2021-05-17
  • 2021-04-11
  • 2021-11-14
  • 2021-12-16
相关资源
相似解决方案