java基礎練習 17

來源:互聯網
上載者:User

標籤:鍵盤   sum   java基礎   str   ann   發放   部分   out   1.5   

import java.util.Scanner;
public class Seventheen {
/*企業發放的獎金根據利潤提成。利潤(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 static void main(String[] args){
Scanner input=new Scanner(System.in);
System.out.println("請輸入當月利潤:");
int a=input.nextInt();
int b,c;
c=a;
double sum=0;
while(a!=0){
if(a>100){
b=a-100;
sum=sum+b*0.01;
a=100;
}
else if(a>60){
b=a-60;
sum=sum+b*0.015;
a=60;
}
else if(a>40){
b=a-40;
sum=sum+b*0.03;
a=40;
}
else if(a>20){
b=a-20;
sum=sum+b*0.05;
a=20;
}
else if(a>10){
b=a-10;
sum=sum+b*0.075;
a=10;
}
else {

sum=sum+a*0.1;
a=0;
}

}
System.out.println(c+"所得的利潤是:"+sum);

}

}

java基礎練習 17

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.