0% found this document useful (0 votes)
31 views6 pages

Project 3 ResutrantManagement

basic python programme

Uploaded by

Majid Islam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views6 pages

Project 3 ResutrantManagement

basic python programme

Uploaded by

Majid Islam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Assignment Title: Restaurant Management System

Objective

The goal of this assignment is to build a simple Restaurant Management System using Python.
This system will allow:

1. Managing the menu (add, remove, or update items).


2. Taking customer orders.
3. Calculating bills with tax and service charges.
4. Handling errors gracefully using exception handling.

Instructions

1. Complete the Program Functionality:


Implement all features listed below.
2. Use Exception Handling:
Handle errors like invalid input, unavailable items, and improper menu management.

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

Enter your choice: 1


Enter item name: Pasta
Enter item price: 12.50
Item added successfully!

Take Orders

Menu:

1. Burger - $5.99
2. Pizza - $8.49
3. Salad - $4.99

Enter item name to order: Pizza


Enter quantity: 2
Order added: Pizza x 2

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: "))

if choice == 1: # Add Item


item_name = input("Enter item name: ").strip().title()
if item_name in self.menu:
print("Item already exists in the menu!")
continue
price = float(input("Enter item price: "))
self.menu[item_name] = price
print(f"Item '{item_name}' added successfully!")

elif choice == 2: # Remove Item


item_name = input("Enter item name to remove: ").strip().title()
if item_name in self.menu:
del self.menu[item_name]
print(f"Item '{item_name}' removed successfully!")
else:
print(f"Error: Item '{item_name}' not found in the menu.")

elif choice == 3: # Update Item Price


item_name = input("Enter item name to update: ").strip().title()
if item_name in self.menu:
price = float(input(f"Enter new price for '{item_name}': "))
self.menu[item_name] = price
print(f"Price of '{item_name}' updated successfully!")
else:
print(f"Error: Item '{item_name}' not found in the menu.")

elif choice == 4: # View Menu


if not self.menu:
print("The menu is empty!")
else:
print("\nCurrent Menu:")
for item, price in self.menu.items():
print(f"{item}: ${price:.2f}")

elif choice == 5: # Exit Management


break

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

if item_name not in self.menu:


print(f"Error: '{item_name}' is not available on the menu.")
continue

quantity = int(input(f"Enter quantity for '{item_name}': "))


if quantity <= 0:
print("Error: Quantity must be greater than 0.")
continue

# Add the order to the order dictionary


if item_name in self.order:
self.order[item_name] += quantity
else:
self.order[item_name] = quantity
print(f"'{item_name}' x {quantity} added to the order.")

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}")

# Calculate tax and service charge


tax = subtotal * 0.05
service_charge = subtotal * 0.10
total = subtotal + tax + service_charge

print(f"\nSubtotal: ${subtotal:.2f}")
print(f"Tax (5%): ${tax:.2f}")
print(f"Service Charge (10%): ${service_charge:.2f}")
print(f"Total: ${total:.2f}")

# Clear the order after calculating the bill


self.order.clear()

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()

You might also like