Java經典編程題50道之十二

來源:互聯網
上載者:User

標籤:mon   public   static   提取   []   rgs   ring   經典   string   

企業發放的獎金根據利潤提成:利潤(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 Example12 {
    public static void main(String[] args) {
        money(1000);
    }


    public static void money(double x) {
        double y = 0;
        if (x > 0 && x <= 10) {
            y = x * 0.1;
        } else if (x > 10 && x <= 20) {
            y = 10 * 0.1 + (x - 10) * 0.075;
        } else if (x > 20 && x <= 40) {
            y = 10 * 0.1 + 10 * 0.075 + (x - 20) * 0.05;
        } else if (x > 40 && x <= 60) {
            y = 10 * 0.1 + 10 * 0.075 + 20 * 0.05 + (x - 40) * 0.03;
        } else if (x > 60 && x <= 100) {
            y = 20 * 0.175 + 20 * 0.05 + 20 * 0.03 + (x - 60) * 0.015;
        } else if (x > 100) {
            y = 20 * 0.175 + 40 * 0.08 + 40 * 0.015 + (x - 100) * 0.01;
        }
        System.out.println("利潤為:"+x+"萬元。\n應該提取的獎金為: " + y + "萬元。");
    }
}

Java經典編程題50道之十二

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.