Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Teachers_Correction {
- public static void main(String [] args) {
- int balance = 0;
- Scanner sc = new Scanner (System.in);
- // show main menu
- System.out.println(" Welcome to Cafe Java! \n \n Main Menu \n 1. Food Menu \n 2. Drink Menu \n 3. Balance \n 4. Exist ");
- System.out.println(" \n Enter the number:");
- int option = sc.nextInt();
- int burger = 0;
- int sandwich = 0;
- int coffee = 0;
- int tea = 0;
- while (option > 0 && option <4) {
- switch (option) {
- case 1:
- // show food menu
- System.out.println(" Food Menu \n \n 1. Burger (MMK 2500) \n 2. Sandwich (MMK 3000) \n 3. Main Menu \n \n Enter your number: ");
- int foodOption = sc.nextInt();
- if (foodOption!= 3) {
- switch(foodOption) {
- case 1:
- System.out.println("Burger Quantity: ");
- int quantity = sc.nextInt();
- burger= quantity*2500;
- System.out.println("MMK " +burger);
- break;
- case 2:
- System.out.println("Sandwich Quantity: ");
- quantity = sc.nextInt();
- sandwich = quantity * 3000;
- System.out.println("MMK " +sandwich);
- break;
- default:
- System.out.println("Invalid");
- break;
- }
- }
- break;
- case 2: // show drink menu
- System.out.println(" Drink Menu \n \n 1. Coffee (MMK 1500) \n 2. Tea (MMK 1500 \n 3. Main Menu");
- int drinkOption = sc.nextInt();
- if (drinkOption!= 3) {
- switch(drinkOption) {
- case 1:
- System.out.println("Quantity: ");
- int quantity = sc.nextInt();
- coffee= quantity*1500;
- System.out.println("MMK "+coffee);
- break;
- case 2:
- System.out.println("Quantity: ");
- quantity = sc.nextInt();
- tea = quantity * 1500;
- System.out.println("MMK " + tea);
- break;
- default:
- System.out.println("Invalid");
- break;
- }
- }
- break;
- case 3:
- balance = burger + sandwich + coffee + tea;
- System.out.println(" Balance: MMK "+ balance);
- break;
- }
- if (option == 4) {
- System.out.println("Thank you!");
- }
- }
- option = sc.nextInt();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement