zoukankan      html  css  js  c++  java
  • 12 应该提取的奖金是

    题目:

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

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

     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 }
  • 相关阅读:
    poj 1328 Radar Installation (贪心)
    hdu 2037 今年暑假不AC (贪心)
    poj 2965 The Pilots Brothers' refrigerator (dfs)
    poj 1753 Flip Game (dfs)
    hdu 2838 Cow Sorting (树状数组)
    hdu 1058 Humble Numbers (DP)
    hdu 1069 Monkey and Banana (DP)
    hdu 1087 Super Jumping! Jumping! Jumping! (DP)
    必须知道的.NET FrameWork
    使用记事本+CSC编译程序
  • 原文地址:https://www.cnblogs.com/liuyangfirst/p/6514310.html
Copyright © 2011-2022 走看看