基础练习题

12 应该提取的奖金是

2023-10-02  本文已影响0人  北极的大企鹅

题目:

企业发放的奖金根据利润提成。 利润(I)低于或等于10万元时,奖金可提10%;利润高于10万元,低于20万元时,

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

 1     public class _012Profit {
 2 
 3     public static void main(String[] args) {
 4         while (true) {
 5             printProfit();
 6         }
 7     }
 8 
 9     private static void printProfit() {
10         double reward = 0.0, profit = 0.0;
11         System.out.println("请输入当月利润(万) :");
12         Scanner scanner = new Scanner(System.in);
13         profit = scanner.nextInt();
14         if (profit > 0 && profit <= 10) {
15             reward = profit * 0.1;
16         } else if (profit > 10 && profit <= 20) {
17             reward = 10 * 0.1 + (profit - 10) * 0.075;
18         } else if (profit > 20 && profit <= 40) {
19             reward = 10 * 0.1 + 10 * 0.075 + (profit - 20) * 0.05;
20         } else if (profit > 40 && profit <= 60) {
21             reward = 10 * 0.1 + 10 * 0.075 + 20 * 0.05 + (profit - 40) * 0.03;
22         } else if (profit > 60 && profit <= 100) {
23             reward = 10 * 0.1 + 10 * 0.075 + 20 * 0.05 + 20 * 0.03
24                     + (profit - 60) * 0.015;
25         } else if (profit > 100) {
26             reward = 20 * 0.175 + 40 * 0.08 + 40 * 0.015 + (profit - 100)
27                     * 0.01;
28         }
29         System.out.println("应该提取的奖金是:" + reward + "万");
30     }
31 }

上一篇下一篇

猜你喜欢

热点阅读