close

/*某大賣場欣逢週年慶,推出促銷折扣方案,消費者購物滿1000 元,即可享有95 折,
3000~4999 元92 折,5000~9999 元9 折,10000 元85 折。試撰寫一程式,計算消費額
為12500 元時,所應支付的金額。
*/
import java.util.Scanner;
public class P5_2_9 {
int show(int price){
int pay=0;
if(price>=1000&&price<2999){
System.out.println("消費者購物滿1000 元,即可享有95 折 消費金額"+price);
pay=(int)(price*0.95);
}
if(price>=3000&&price<4999){
System.out.println("消費者購物滿3000~4999 元,即可享有92 折 消費金額"+price);
pay=(int)(price*0.92);
}
if(price>=5000&&price<9999){
System.out.println("消費者購物滿5000~9999 元,即可享有9 折 消費金額"+price);
pay=(int)(price*0.90);
}
if(price>=10000){
System.out.println("消費者購物滿10000元,即可享有85 折 消費金額"+price);
pay=(int)(price*0.85);

}
return pay;
}

public static void main(String[] args) {
System.out.println("請輸入消費金額");
Scanner sc=new Scanner(System.in);
int port =sc.nextInt();
P5_2_9 p=new P5_2_9();
System.out.println("所應支付的金額"+p.show(port));
}

}

/*

請輸入消費金額
1100
消費者購物滿1000 元,即可享有95 折 消費金額1100
所應支付的金額1045

*/

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 goodlucky23 的頭像
    goodlucky23

    goodlucky23的部落格

    goodlucky23 發表在 痞客邦 留言(0) 人氣()