Advertisement
MrDoyle

Untitled

Oct 22nd, 2020
2,018
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.60 KB | None | 0 0
  1. import java.util.HashMap;
  2. import java.util.Scanner;
  3.  
  4. public class Main {
  5.  
  6.     public static void main(String[] args) {
  7.         HashMap<String, Integer> myMenu = new HashMap<String, Integer>();
  8.         myMenu.put("Bread", 70000);
  9.         myMenu.put("Big_Cookies", 12000);
  10.         myMenu.put("Small_Cookies", 12000);
  11.         myMenu.put("Chocolate_Brownies", 9000);
  12.         myMenu.put("Arequipe_Brownies", 9000);
  13.         myMenu.put("Simple_Brownies", 8000);
  14.         myMenu.put("Cheesecake", 6000);
  15.         myMenu.put("Cinnamon Rolls", 6000);
  16.         myMenu.put("Lemon Mug Cake", 12000);
  17.  
  18.         System.out.println("Menu:");
  19.  
  20.         int menuSlot = 1;
  21.         for (String name : myMenu.keySet()) {
  22.             System.out.println("Item #" + menuSlot + ": " + name + " = " + myMenu.get(name));
  23.             menuSlot++;
  24.         }
  25.  
  26.         Scanner keyboard = new Scanner(System.in);
  27.         String order = " ";
  28.         int orderTotal = 0;
  29.  
  30.         while (!(order.equals("exit"))) {
  31.             System.out.println("Please enter the name of the item you wish to purchase. Type exit when your list is complete");
  32.             order = keyboard.nextLine();
  33.             if (order.equals("exit")) {
  34.  
  35.             }else {
  36.                 System.out.println("You ordered: " + order);
  37.                 System.out.println("Great! How many would you like?");
  38.                 Scanner quantity = new Scanner(System.in);
  39.                 int Quanitity = quantity.nextInt();
  40.                 orderTotal = orderTotal + (myMenu.get(order) * Quanitity);
  41.             }
  42.         }
  43.         System.out.println("code end");
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement