def write_reservation_to_file(reservation_data):
with open("reservation_StudentID.txt", "a") as file:
file.write(",".join(reservation_data) + "\n")
def write_menu_item_to_file(menu_item_data):
with open("menuItems_StudentID.txt", "a") as file:
file.write(",".join(menu_item_data) + "\n")
def add_reservation():
... (Same as before)
def cancel_reservation():
... (Same as before)
def update_reservation():
Implement code to update/edit a reservation based on the provided requirements
# You will need to read the "reservation_StudentID.txt" file, update the specific reservation, and write the updated data back to the file.
pass
def display_reservations():
Implement code to display all reservations stored in "reservation_StudentID.txt" with appropriate headings for each column
pass
def generate_meal_recommendation():
Implement code to read "menuItems_StudentID.txt" and generate meal recommendations
pass
def main_menu():
Read existing reservation and menu item data upon starting the program
# You can store the reservation data in a list for manipulation during the program's execution
# Similarly, you can store menu item data in a list for generating recommendations
reservations = []
with open("reservation_StudentID.txt", "r") as file:
for line in file:
reservations.append(line.strip().split(","))
menu_items = []
with open("menuItems_StudentID.txt", "r") as file:
for line in file:
menu_items.append(line.strip().split(","))
while True:
print("\nMain Menu:")
print("1. Add Reservation")
print("2. Cancel Reservation")
print("3. Update/Edit Reservation")
print("4. Display Reservations")
print("5. Generate Meal Recommendation")
print("6. Exit")
choice = input("Enter your choice: ")
if choice == "1":
add_reservation()
elif choice == "2":
cancel_reservation()
elif choice == "3":
update_reservation()
elif choice == "4":
display_reservations()
elif choice == "5":
generate_meal_recommendation()
elif choice == "6":
print("Exiting the program.")
# Write updated reservation data back to the file before exiting
with open("reservation_StudentID.txt", "w") as file:
for reservation in reservations:
file.write(",".join(reservation) + "\n")
break
else:
print("Invalid choice. Please try again.")
def write_reservation_to_file(reservation_data): with open("reservation_StudentID.txt", "a") as file: file.write(",".join(reservation_data) + "\n")
def write_menu_item_to_file(menu_item_data): with open("menuItems_StudentID.txt", "a") as file: file.write(",".join(menu_item_data) + "\n")
def add_reservation():
... (Same as before)
def cancel_reservation():
... (Same as before)
def update_reservation():
Implement code to update/edit a reservation based on the provided requirements
def display_reservations():
Implement code to display all reservations stored in "reservation_StudentID.txt" with appropriate headings for each column
def generate_meal_recommendation():
Implement code to read "menuItems_StudentID.txt" and generate meal recommendations
def main_menu():
Read existing reservation and menu item data upon starting the program
if name == "main": main_menu()