代码实现:企业发放的奖金根据利润提成。利润(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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import java.util.Scanner;
 
/*
 企业发放的奖金根据利润提成。利润(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%提成,
 从键盘输入当月l利润I,求应发放奖金总数?
 程序分析:请利用数轴来分界,定位。注意定义时需把奖金定义成长整型。*/
 
public class Test12 {
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入利润(注意 : 利润为整数,单位:元)");
        long profit = 0;
        while (true) {
            String s = sc.nextLine();
            try {
                profit = Integer.parseInt(s);
                break;
            } catch (NumberFormatException e) {
                System.out.println("录入错误,请重新输入整数(单位:元):");
            }
        }
        System.out.println("应发奖金:" + bonus(profit));
    }
 
    private static long bonus(long profit) {
        long prize = 0;
        long profit_sub = profit;
        if (profit > 1000000) {
            profit = profit_sub - 1000000;
            profit_sub = 1000000;
            prize += profit * 0.01;
        }
        if (profit > 600000) {
            profit = profit_sub - 600000;
            profit_sub = 600000;
            prize += profit * 0.015;
        }
        if (profit > 400000) {
            profit = profit_sub - 400000;
            profit_sub = 400000;
            prize += profit * 0.03;
        }
        if (profit > 200000) {
            profit = profit_sub - 200000;
            profit_sub = 200000;
            prize += prize * 0.05;
        }
        if (profit > 100000) {
            profit = profit_sub - 100000;
            profit_sub = 100000;
            prize += profit * 0.075;
        }
        prize += profit_sub * 0.1;
        return prize;
    }
}

 

posted on   LoaderMan  阅读(2686)  评论(0编辑  收藏  举报

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

喜欢请打赏

扫描二维码打赏

了解更多

点击右上角即可分享
微信分享提示