訂餐系統(Dome)

mpsky發表於2021-09-09
import java.util.Scanner;
public class OrderingMsg {
public static void main(String[] args) throws Exception {
    Scanner scanner = new Scanner(System.in);
    String[] names = new String[6]; // 訂餐人姓名
    String[] dishMsgs = new String[6];// 選擇菜品
    int[] numbers = new int[6];// 菜品份數
    int[] times = new int[6]; // 送餐時間
    String[] addresses = new String[6];// 送餐地址
    int[] states = new int[6];// 訂單狀態 0:已經預定 1:已經完成
    double[] sumPrices = new double[6];// 總金額
    int[] praiseNums = new int[6];
    String[] dishNames = { "北京烤鴨", "麻婆豆腐", "松鼠魚", "紅燒帶魚", "時令蔬菜", "辣土豆絲" };
    double[] prices = { 88, 24, 38, 35, 15, 12 };
    System.out.println("歡迎進入surper訂餐系統");
    int num = -1; // 輸入0 預設返回主選單
    boolean isExit = false;// 預設不退出
    do {
        System.out.println("**********************");
        System.out.println("1:我要訂餐");
        System.out.println("2:檢視餐袋");
        System.out.println("3:簽收訂單");
        System.out.println("4:刪除訂單");
        System.out.println("5:我要點贊");
        System.out.println("6:退出系統");
        System.out.println("**********************");
        System.out.println("請選擇:");
        int choice = scanner.nextInt(); //選擇你所需要的服務
        switch (choice) {
        case 1:
            System.out.println("************我要訂餐************");
            boolean empty = false;//作一個標記
            for (int i = 0; i  0) ? praiseNums[j]
                                + "個贊"
                                : "";
                        System.out.println(j + 1 + "ttt" + dishNames[j]
                                + "ttt" + prices[j] + "ttt"
                                + praiseNum);
                    }
                    // 使用者開始點菜,並收集資訊
                    System.out.println("請您選擇菜品的編號:");
                    int choiceName = scanner.nextInt();
                    System.out.println("請您輸入點餐的份數:");
                    int number = scanner.nextInt();
                    System.out.println("請您輸入送餐的地址:");
                    String address = scanner.next();
                    System.out.println("請您輸入送餐的時間:");
                    System.out.println("本店整點送餐:8點至20點");
                    int time = scanner.nextInt();
                    double sumPrice = prices[choiceName - 1] * number;
                    double price = (sumPrice >=50) ? 0 : 5;//判斷是否收取運費
                    System.out.println("訂單已生成!");
                    System.out.println("您定的菜品是:"+ dishNames[choiceName - 1] + "t" + number+ "份");
                    System.out.print("餐費:" + sumPrice);
                    System.out.print("t送餐費:" + price);
                    System.out.println("t總費用:" + (price + sumPrice));
                    // 把輸入的資訊塞進陣列中
                    times[i] = time; // 時間
                    addresses[i] = address; // 地址
                    sumPrices[i] = (sumPrice + price); // 總金額
                    dishMsgs[i] = dishNames[choiceName - 1]; // 定的菜品
                    states[i] = 0; // 訂餐的狀態
                    numbers[i] = number; // 份數
                    break;
                }
            }
            if (!empty) {// 餐袋已經滿了
                System.out.println("餐袋已經滿了");
            }
            break;
        case 2:
            System.out.println("************檢視餐袋************");
            System.out.println("編號tt訂餐人tt菜品(份數)tt送餐時間 tt送餐地址tt總金額tt狀態tt點贊數量");
            for (int i = 0; i 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/1806/viewspace-2800118/,如需轉載,請註明出處,否則將追究法律責任。

相關文章