In: Computer Science
Le Chef Heureux Restaurant has 20 tables that can be reserved at 5 p.m., 7 p.m., or 9 p.m. Design a program that accepts reservations for specific tables at specific times; the user enters the number of customers, the table number, and the time. Do not allow more than four guests per table or invalid table numbers or times. If an attempt is made to reserve a table already taken, reprompt the user. Continue to accept reservations until the user enters a sentinel value or all slots are filled. Then display all empty tables in each time slot.
create a solution algorithm using pseudocode
create a flowchart
Solution Algorithm:
create 2 D list , each row will represent 1 table and each
table will have 3 columns representing the times - 5pm 7pm and 9pm
booking_slots from range 0 to 20
while True:
customers = int(input('Enter the number of customers (0 to exit): '))
if customers greater than 4:
print('Only 4 customers are allowed per table.')
continue
elif customers == 0:
break
else:
table_number = int(input('Enter table # (1-20): '))
if 1 less than table_number and table_number <= 20:
time equals int(input('[1]-5pm [2]-7pm [3]-9pm Enter 1-3: '))
if 1 less than or equal to time and time <= 3:
if booking_slots[table_number - 1][time - 1] == 0:
booking_slots[table_number - 1][time - 1] = customers
print('Table reserved!')
else:
print('Table already booked. Table not available at this time.')
else:
print('Sorry! You entered an invalid table #.')
continue
else:
print('Sorry! You entered an invalid table #.')
continue
print('Empty Tables')
for table in range(20):
for i in range(3):
if booking_slots[table][i] == 0 and i == 0:
print('Table# {} at 5p.m available'.format(table + 1))
elif booking_slots[table][i] == 0 and i == 1:
print('Table# {} at 7p.m available'.format(table + 1))
elif booking_slots[table][i] == 0 and i == 2:
print('Table# {} at 9p.m available'.format(table + 1))
Let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please leave a +ve feedback : ) Let me know for any help with any other questions. Thank You! ===========================================================================