[go: up one dir, main page]

0% found this document useful (0 votes)
28 views2 pages

Notes

This Python code defines classes and functions to create a menu for a hotel and calculate customer bills. The HotelMenu class initializes a menu dictionary and contains methods to print the menu and get item information. The calculate_bill function takes user choices and the menu to create a bill dictionary. The main function runs the program - it initializes the menu, gets user input for choices and information, calculates the bill, and prints the results.

Uploaded by

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

Notes

This Python code defines classes and functions to create a menu for a hotel and calculate customer bills. The HotelMenu class initializes a menu dictionary and contains methods to print the menu and get item information. The calculate_bill function takes user choices and the menu to create a bill dictionary. The main function runs the program - it initializes the menu, gets user input for choices and information, calculates the bill, and prints the results.

Uploaded by

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

import uuid

class HotelMenu:
def __init__(self):
self.menu_items = {
1: {"name": "SHAHI PANEER", "price": 149},
2: {"name": "PANEER BUTTER MASALA", "price": 159},
3: {"name": "KARAHI PANEER", "price": 135},
4: {"name": "DAL MAKHNI", "price": 145},
5: {"name": "MIX VEG.", "price": 95},
}

def print_menu(self):
print("Welcome to our Hotel Menu!")
print("{:<10} {:<25} {:<10}".format("ITEM NO.", "NAMNE", "PRICE"))
print("=" * 45)
for item_num, item_info in self.menu_items.items():
print("{:<10} {:<25} ₹{:<10.2f}".format(item_num, item_info['name'],
item_info['price']))

def get_item_info(self, choice):


return self.menu_items.get(choice, {})

def calculate_bill(choices, menu):


bill_dict = {}

for choice, quantity in choices.items():


item_info = menu.get_item_info(choice)
if item_info:
name = item_info.get('name')
price = item_info.get('price')

if name in bill_dict:
bill_dict[name]['quantity'] += quantity
else:
bill_dict[name] = {'quantity': quantity, 'price': price}

return bill_dict

def generate_customer_id():
return str(uuid.uuid4())

def main():
hotel_menu = HotelMenu()
user_choices = {}

# Ask for user information


name = input("Enter your name: ")
contact = input("Enter your contact number: ")
address = input("Enter your address: ")

# Generate random customer ID


customer_id = generate_customer_id()

while True:
hotel_menu.print_menu()

try:
choice = int(input("\nENTER your choice (1-5) for selecting every item and
you will get menu until you select 0, or ENTER 0 to get the total bill: "))
if choice == 0:
break
elif 1 <= choice <= 5:
quantity = int(input(f"Enter the quantity for item {choice}: "))
user_choices[choice] = quantity
else:
print("Invalid choice. Please choose a number between 1 and 5.")
except ValueError:
print("Invalid input. Please enter a number.")

bill_info = calculate_bill(user_choices, hotel_menu)

print("\nYour Total Bill:")

print("\nCUSTOMER INFORMATION:")
print(f"Name: {name}")
print(f"Contact Number: {contact}")
print(f"Address: {address}")
print(f"Customer ID: {customer_id}")
print("\nYOUR ITEM")
for name, item_info in bill_info.items():
print(f"Item {name}: Quantity - {item_info['quantity']},
₹{item_info['price']:.2f} each")

total_bill = sum(item_info['quantity'] * item_info['price'] for item_info in


bill_info.values())

print(f"\nTotal Bill: ₹{total_bill:.2f}")


if total_bill == 0:
print("\nYOU HAVE NOT PURCHASED ANY ITEM")
elif total_bill > 0:
print("\nTHANK YOU FOR VISITING OUR WEBSITE")

# Display user information

if __name__ == "__main__":
main()

You might also like