Using Dictionary Collections
Create the following UI for menu items: then allow the user to input orders
The user will continue to input orders until q is typed to quit. Then display the summary of orders with the total bill.
1. Use a dictionary(for the menu) and List(for the orders in the cart)
2. Users may input the same item in the cart.
3. Follow the exact format and whitespace for the menu
4. User input should be case insensitive
5. If the user inputted an item not in the Menu – it will not include it in the cart and display “Not Available” and input another item
6. Create a MENU with 10 items and assign prices in Peso (php) - You may choose what items you would like to put in your cart
menu = {
"Water": 15,
"Burger": 50,
"Spaghetti": 75,
"Soda": 25,
"Chicken": 60,
"Steak": 85,
"Nuggets": 50,
"Fries": 40,
"Juice": 25,
"Pie": 45
}
cart = []
prices = []
print("-------- MENU --------")
for item, price in menu.items():
print(f"{item:15}: ₱{price}")
while True:
order = input("Enter a food to buy (q to quit): ").strip().title()
if order.lower() == "q":
break
elif order in menu:
cart.append(order)
prices.append(menu[order])
print(f"Added {order} - ₱{menu[order]}")
else:
print("Not Available")
print("\n----- YOUR ORDERS -----")
total = 0
for item, price in zip(cart, prices):
print(f"{item:15} ₱{price}")
total += price
print(f"\nYour total is: ₱{total}")
-------- MENU --------
Water : ₱15
Burger : ₱50
Spaghetti : ₱75
Soda : ₱25
Chicken : ₱60
Steak : ₱85
Nuggets : ₱50
Fries : ₱40
Juice : ₱25
Pie : ₱45
Enter a food to buy (q to quit): water
Added Water - ₱15
Enter a food to buy (q to quit): soda
Added Soda - ₱25
Enter a food to buy (q to quit): q
----- YOUR ORDERS -----
Water ₱15
Soda ₱25
Your total is: ₱40