Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.HashMap;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- HashMap<String, Integer> myMenu = new HashMap<String, Integer>();
- myMenu.put("Muffin", 10000);
- myMenu.put("Coffee", 8000);
- myMenu.put("Chocolate", 4000);
- System.out.println("These are the items on our Menu");
- int menuSlot = 1;
- for (String name:myMenu.keySet()){
- System.out.println("Item #" + menuSlot + ": " + name + " = " + myMenu.get(name));
- menuSlot ++;
- }
- String order = " ";
- int orderTotal = 0;
- while (!(order.equals("exit")) ){
- System.out.println("Please enter the name of the item you wish to purchase. Type exit when your list is complete");
- order = input.next();
- if (order.equals("exit")){
- break;
- }else{
- orderTotal = orderTotal + myMenu.get(order);
- }
- }
- System.out.println("Your total for this order is: " + orderTotal);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement