bill calculation of all-you-can-eat


Submit solution

Points: 20
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type

題目說明

<1112檢定考題>
某吃到飽自助餐廳,收費方式如下所示:

平日 假日
午餐 $955/人 $1065/人
下午茶 $768/人 $955/人
晚餐 $1065/人 $1175/人

小孩五折優待,單筆消費人數(含小孩)20人以上總價後打九折。
之後再加上一成(10%)小費,四捨五入到整數,為應支付總金額。
由鍵盤輸入消費時段與消費人數為幾個大人幾個小孩之後,計算應支付的總金額。

輸入

(a)由鍵盤輸入三個數字,第一個數字為用餐時段,第二個數字代表幾個大人,第三個數字代表幾個小孩
(b)用餐時段如下說明:
1代表平日午餐
2代表平日下午茶
3代表平日晚餐
4代表假日午餐
5代表假日下午茶
6代表假日晚餐

輸出

由螢幕輸出單價(如果有打九折請註明),以及應支付總金額。

sample input & output

輸入 輸出
樣本1 1 2 2 平日午餐 $955/人
應支付金額為 $3152
樣本2 2 1 0 平日下午茶 $768/人
應支付金額為 $845
樣本3 6 20 5 假日晚餐 $1175/人,打九折
應支付金額為 $26173

Comments


  • 0
    scu13156249  commented on Nov. 13, 2024, 12:29 a.m. edit 3

    .


  • 0
    scu10156242  commented on Dec. 16, 2023, 1:22 a.m.

    import java.util.Scanner;

    public class pra10 {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner input =new Scanner(System.in);
        int t= input.nextInt();
        int a =input.nextInt();
        int c =input.nextInt();
        double price =0.0;
        int iprice =0;
        if(t==1) {
            System.out.print("平日午餐$955/人");
            price=(a*955)+((c*955)/2);
        }else if(t==2) {
            System.out.print("平日下午茶$768/人");
            price=(a*768)+((c*768)/2);
        }else if(t==3) {
            System.out.print("平日晚餐$1065/人");
            price=(a*1065)+((c*1065)/2);
        }else if(t==4) {
            System.out.print("假日午餐$1065/人");
            price=(a*1065)+((c*1065)/2);
        }else if(t==5) {
            System.out.print("假日下午茶$955/人");
            price=(a*955)+((c*955)/2);
        }else if(t==6) {
            System.out.print("假日晚餐$1175/人");
            price=(a*1175)+((c*1175)/2);
        }
    
        if((a+c)>=20) {
        System.out.println(",打九折");
        price= (price/10)*9;
    }else {
        System.out.println();
    }
    
        price=price+(price/10);
    price =Math.round(price);
    iprice=(int)price;
    System.out.print("應支付金額為$"+iprice);
    
    
    
    
    
    
    
    
    
    
    }

    } 哪裡錯了?


    • 0
      scu10156255  commented on Dec. 19, 2023, 3:54 p.m.

      加空格