Will truncate only the line that user inputted Will compute the total number of Adults of all reservation Will compute the tolal number of Children of all reservation and will compute the Grand Total of all reservation Use Python Programming - restaurant reservation program. The application offers different reservation rate for adults and children. (see sample below) RESTAURANT RESERVATION SYSTEM System Menu a. View all Reservations b. Make Reservation c. Delete Reservation d. Generate Report e. Exit 2. When the VIEW RESERVATIONS is clicked, this will display all the reservations made: # Date Time Name Adults Children 1 Nov 10, 2020 10:00 am John Doe 1 1 2 Nov 25, 2020 11:00 am Michelle Franks 2 1 3 Dec 10, 2020 9:00 am Ella Flich 1 1 4 Dec 21, 2020 12:00 pm Dylan Cloze 2 1 3. If the user selects MAKE RESERVATION, the user needs to input the following: a. Name (String) b. Date (String) c. Time (String) d. No of Adults (Integer) e. No of Children (Integer) Note: Adult is 500 per head and Kids is 300 per head reservation, save the data in a text file. 4. If DELETE RESERVATION is selected, the user needs to input the reservation number to remove the existing reservation. 5. If the GENERATE REPORT is clicked, display the report of all reservations: reservation = {} rnum = 0 while True: mylist= [] choice = input('\nRESTAURANT RESERVATION SYSTEM\nSystem Menu\na. View all Reservations\nb. Make Reservation\nc. Delete Reservation\nd. Generate Report\ne. Exit\nEnter choice --> ').lower() f1 = open("reservation.txt", "a") if(choice == "a"): f2 = open("reservation.txt", "r") print("Records are:") print(f2.read()) f2.close() elif(choice =="b"): try: rnum += 1 name = input("Enter Name: ") Date = input("Enter date(DD-MM-YYYY): ") Time = input("Enter time(HH:MM): ") adults = input("Number of adults: ") Children = input("Number os children: ") f1.write (str(int(rnum))) f1.write("\t") f1.write(Date) f1.write("\t") f1.write(Time) f1.write("\t\t") f1.write(name) f1.write("\t\t") f1.write(adults) f1.write("\t\t") f1.write(Children) f1.write("\t") total = int(adults)*500 + int(Children)*300 reservation[rnum]= [Date,Time,name,adults,Children,total] f1.write(str(total)) f1.write("\n") f1.close() print("\nBelow are your Reservation Details:") print( f"Reservation Number\t\t{rnum}\nName\t\t{name}\nDate\t\t{Date}\nTime\t\t\{Time}\nTotal Adults\t\t{adults}\nTotal children\t\t{Children}\n") print(reservation) except ValueError: print("there is an incorrect value!! try again") elif(choice == "c"): getindex = 0; rnumd = int(input("Enter Reservation number:")) try: f1.truncate(rnumd) f1.close() print("No Record found") except KeyError: print("Invalid reservation ID") print("Reservation deleted") elif(choice == "d"): f2 = open("reservation.txt", "r") print("Records are:") print(f2.read()) print("Total Number of Adults: " ) print("Total Number of Children: ") print("Grand Total : ") f2.close() elif(choice == "e"): break
Will truncate only the line that user inputted
Will compute the total number of Adults of all reservation
Will compute the tolal number of Children of all reservation
and will compute the Grand Total of all reservation
Use Python Programming - restaurant reservation program. The application offers different reservation rate for adults and children. (see sample below)
RESTAURANT RESERVATION SYSTEM
System Menu
a. View all Reservations
b. Make Reservation
c. Delete Reservation
d. Generate Report
e. Exit
2. When the VIEW RESERVATIONS is clicked, this will display all the reservations made:
# Date Time Name Adults Children 1 Nov 10, 2020 10:00 am John Doe 1 1 2 Nov 25, 2020
11:00 am Michelle Franks 2 1 3 Dec 10, 2020 9:00 am Ella Flich 1 1 4 Dec 21, 2020 12:00 pm
Dylan Cloze 2 1
3. If the user selects MAKE RESERVATION, the user needs to input the following:
a. Name (String)
b. Date (String)
c. Time (String)
d. No of Adults (Integer)
e. No of Children (Integer)
Note: Adult is 500 per head and Kids is 300 per head reservation, save the data in a text file.
4. If DELETE RESERVATION is selected, the user needs to input the reservation number to remove the existing reservation.
5. If the GENERATE REPORT is clicked, display the report of all reservations:
reservation = {}
rnum = 0
while True:
mylist= []
choice = input('\nRESTAURANT RESERVATION SYSTEM\nSystem Menu\na. View all Reservations\nb. Make Reservation\nc. Delete Reservation\nd. Generate Report\ne. Exit\nEnter choice --> ').lower()
f1 = open("reservation.txt", "a")
if(choice == "a"):
f2 = open("reservation.txt", "r")
print("Records are:")
print(f2.read())
f2.close()
elif(choice =="b"):
try:
rnum += 1
name = input("Enter Name: ")
Date = input("Enter date(DD-MM-YYYY): ")
Time = input("Enter time(HH:MM): ")
adults = input("Number of adults: ")
Children = input("Number os children: ")
f1.write (str(int(rnum)))
f1.write("\t")
f1.write(Date)
f1.write("\t")
f1.write(Time)
f1.write("\t\t")
f1.write(name)
f1.write("\t\t")
f1.write(adults)
f1.write("\t\t")
f1.write(Children)
f1.write("\t")
total = int(adults)*500 + int(Children)*300
reservation[rnum]= [Date,Time,name,adults,Children,total]
f1.write(str(total))
f1.write("\n")
f1.close()
print("\nBelow are your Reservation Details:")
print(
f"Reservation Number\t\t{rnum}\nName\t\t{name}\nDate\t\t{Date}\nTime\t\t\{Time}\nTotal Adults\t\t{adults}\nTotal children\t\t{Children}\n")
print(reservation)
except ValueError:
print("there is an incorrect value!! try again")
elif(choice == "c"):
getindex = 0;
rnumd = int(input("Enter Reservation number:"))
try:
f1.truncate(rnumd)
f1.close()
print("No Record found")
except KeyError:
print("Invalid reservation ID")
print("Reservation deleted")
elif(choice == "d"):
f2 = open("reservation.txt", "r")
print("Records are:")
print(f2.read())
print("Total Number of Adults: " )
print("Total Number of Children: ")
print("Grand Total : ")
f2.close()
elif(choice == "e"):
break
Step by step
Solved in 3 steps with 1 images