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

Bakery Management Code

Uploaded by

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

Bakery Management Code

Uploaded by

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

import random

# Bakery menu
menu = {
"Cake": 500,
"Cookies": 200,
"Pastries": 150,
"Ice creams": 60,
"Chocolates": 50,
"Cream puffs": 180,
"Donuts": 120,
}

# Function to display the menu


def display_menu():
print("Welcome to the Bakery!")
print("Here is the menu:")
for item, price in menu.items():
print(f"{item}: ${price:.2f}")
print()

# Function to get user details and save to a file


def inputs():
name = input("Enter your name: ")
phone_no = input("Enter your phone number: ")

# Save details to a file


with open("customer_details.txt", "w") as f:
f.write(f"Name: {name}\n")
f.write(f"Phone Number: {phone_no}\n")

return name, phone_no

# Function to take the order from the user and save to a file
def take_order():
order = {}
while True:
item = input("Enter the item you want to order (or 'done' to finish):
").capitalize()
if item == 'Done':
break
elif item in menu:
quantity = int(input(f"How many {item}(s) would you like to order? "))
if item in order:
order[item] += quantity
else:
order[item] = quantity
else:
print(f"Sorry, we don't have {item} on the menu.")

# Save order details to a file


with open("order_details.txt", "w") as f:
f.write("Order Summary:\n")
for item, quantity in order.items():
f.write(f"{item}: {quantity} @ ${menu[item]:.2f} each\n")

return order
# Function to generate a random order ID and save it to a file
def generate_order_id():
nums = "0123456789"
order_id = "".join(random.choice(nums) for _ in range(13))

# Save order ID to a file


with open("order_id.txt", "w") as f:
f.write(f"Order ID: {order_id}\n")

return order_id

# Function to update user details and save to a file


def update_details():
update = input("Do you want to update your details (y/n): ").lower()
if update == 'y':
update_both = input("Do you want to update your name and phone number
(y/n): ").lower()
if update_both == 'y':
name = input("Enter the updated name: ")
phone_no = input("Enter the updated phone number: ")

# Update customer details file


with open("customer_details.txt", "w") as f:
f.write(f"Name: {name}\n")
f.write(f"Phone Number: {phone_no}\n")

print("Details updated.")
else:
print("No changes made.")
else:
print("No changes made.")

# Main program
display_menu()
name, phone_no = inputs()
order = take_order()
order_id = generate_order_id()

print(f"Your order ID is: {order_id}")


update_details()

You might also like