Untitled

 avatar
unknown
plain_text
10 months ago
3.0 kB
22
Indexable
/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 */

package com.mycompany.restaurantmenunilea;
import java.util.Scanner;
/**
 * Restaurant Menu Program
 * @author Lea
 */
public class Restaurantmenunilea {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        System.out.println("==================================================");
        System.out.println("         WELCOME TO RL'S RESTAURANT ");
        System.out.println("    LOCATION: 069, STA. CRUZ, ILOCOS SUR"); 
        System.out.println("==================================================");

        // Display the menu
        System.out.println("MENU");
        System.out.println("1. Kimchi Rolls            - PHP  115");
        System.out.println("2. Tofu Sisig              - PHP  199");
        System.out.println("3. Tiramisu Cake Slice     - PHP  270");
        System.out.println("4. Soda                    - PHP  30 ");
        System.out.println("5. Exit");
        System.out.print("Enter the menu number of your choice: ");

        // Read user choice
        int choice = scanner.nextInt();

        int itemPrice = 0;
        String itemName = "";

        // Use switch to determine item and price
        switch (choice) {
            case 1:
                itemName = "Kimchi Rolls";
                itemPrice = 115;
                break;
            case 2:
                itemName = "Tofu Sisig";
                itemPrice = 199;
                break;
            case 3:
                itemName = "Tiramisu Cake Slice";
                itemPrice = 270;
                break;
            case 4:
                itemName = "Soda";
                itemPrice = 30;
                break;
            case 5:
                System.out.println("=================================================="); 
                System.out.println("        Thank you for your order!");
                scanner.close();
                return;
            default:
                System.out.println("Invalid choice!");
                scanner.close();
                return;
        }

        // Prompt for quantity
        System.out.print("Enter the quantity: ");
        int quantity = scanner.nextInt();

        // Validate quantity
        if (quantity <= 0) {
            System.out.println("Invalid quantity!");
            scanner.close();
            return;
        }

        // Calculate total for selected item
        int totalBill = itemPrice * quantity;

        // Display order summary (exact format)
        System.out.println("You ordered " + itemName + ".");
        System.out.println("Total amount: PHP" + totalBill);

        System.out.println("=================================================="); 
        System.out.println("       Thank you for your order!");
        
        scanner.close();
    }
}

Editor is loading...
Leave a Comment