Project 3 ResutrantManagement
Project 3 ResutrantManagement
Objective
The goal of this assignment is to build a simple Restaurant Management System using Python.
This system will allow:
Instructions
Requirements
Features to Implement
1. Menu Management:
o Allow the manager to:
Add new menu items with prices.
Remove items from the menu.
Update the price and quantity of existing items.
2. Take Orders:
o Display the menu to customers.
o Allow customers to select items and quantities.
o Validate that items exist in the menu.
3. Bill Calculation:
o Calculate the total cost, including:
10% service charge.
5% tax.
4. Error Handling:
o Handle invalid inputs (e.g., non-numeric prices, nonexistent menu items).
5. Exit System:
o Allow users to exit the system gracefully.
Sample Output:
Restaurant System:
1. Manage Menu
2. Take Order
3. Calculate Bill
4. Exit
Enter your choice:
Menu Management:
1. Add Item
2. Remove Item
3. Update Item Price
4. View Menu
5. Exit Management
Take Orders
Menu:
1. Burger - $5.99
2. Pizza - $8.49
3. Salad - $4.99
Bill Calculation
Order Summary:
Pizza x 2 = $16.98
Tax (5%): $0.85
Service Charge (10%): $1.70
Total: $19.53
Solution:
class Restaurant:
def __init__(self):
self.menu = {} # Dictionary to store menu items and prices
self.order = {} # Dictionary to store orders
def manage_menu(self):
while True:
print("\nMenu Management:")
print("1. Add Item")
print("2. Remove Item")
print("3. Update Item Price")
print("4. View Menu")
print("5. Exit Management")
try:
choice = int(input("Enter your choice: "))
else:
print("Invalid choice. Please try again.")
except ValueError:
print("Error: Please enter a valid number.")
def take_order(self):
if not self.menu:
print("The menu is empty. Please add items before taking orders.")
return
print("\nCurrent Menu:")
for item, price in self.menu.items():
print(f"{item}: ${price:.2f}")
while True:
try:
item_name = input("Enter item name to order (or 'done' to finish): ").strip().title()
if item_name.lower() == 'done':
break
except ValueError:
print("Error: Please enter a valid number for quantity.")
def calculate_bill(self):
if not self.order:
print("No items in the order. Please take an order first.")
return
print("\nOrder Summary:")
subtotal = 0
for item, quantity in self.order.items():
price = self.menu[item]
item_total = price * quantity
subtotal += item_total
print(f"{item} x {quantity} = ${item_total:.2f}")
print(f"\nSubtotal: ${subtotal:.2f}")
print(f"Tax (5%): ${tax:.2f}")
print(f"Service Charge (10%): ${service_charge:.2f}")
print(f"Total: ${total:.2f}")
def run(self):
while True:
print("\nRestaurant System:")
print("1. Manage Menu")
print("2. Take Order")
print("3. Calculate Bill")
print("4. Exit")
try:
choice = int(input("Enter your choice: "))
if choice == 1:
self.manage_menu()
elif choice == 2:
self.take_order()
elif choice == 3:
self.calculate_bill()
elif choice == 4:
print("Exiting... Thank you!")
break
else:
print("Invalid choice. Please try again.")
except ValueError:
print("Error: Please enter a valid number.")
if __name__ == "__main__":
restaurant = Restaurant()
restaurant.run()