Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(2) Scheduling Reservations Write a program called reservations.c that simulates some people trying to reserve seats at a restaurant for dinner. The program MUST work

(2) Scheduling Reservations Write a program called reservations.c that simulates some people trying to reserve seats at a restaurant for dinner. The program MUST work as follows: The restaurant takes reservations anywhere from 4pm until 9pm. That means someone can phone in and ask to reserve a table for a certain number of people starting at some specific time in the range of 4pm until 9pm. The people are allowed to stay past 9pm, but no more reservations can be made after 9pm. The restaurant can seat at most 80 people at any time, on any day of the week. Reservations may be made at 15-minute intervals starting at 4pm. Hence, 4:00pm, 4:15pm, 4:30pm, 4:45pm, 5:00pm, 5:15pm, ., 8:45pm, 9:00pm. The program MUST keep track of reservations by using a two dimensional array to indicate the number of patrons in the restaurant at any given timeslot. The program must attempt to make 100 random (must be unique each time you run) reservations by choosing o A random day of the week o A random timeslot (i.e., there are 21 options from 4pm-9pm) o A random size (i.e., number of people) for that reservation which can be at most 40 For each attempted reservation, you should show (nicely on he terminal window) the number of people for the reservation, the day of the week and the start time of the reservation. If the reservation is able to be made, it should indicate that the reservation was accepted, otherwise it should indicate that it was denied. In order to accept a reservation we need to estimate the length of stay for each reservation. Assume the following: o If the reservation is for 2 people, the estimate length of stay is 60 minutes. o If the reservation is between 3-7 people, the estimate is for 75 minutes. o If the reservation is between 8-11 people, the estimate is for 105 minutes. o Otherwise the estimate should be for 120 minutes. The program should accept the reservation if the restaurant can hold that many people for the duration of the estimated length of stay. For example, if a 5pm reservation for 4 people is made, you need to ensure that there are at most 76 people (i.e., restaurant capacity minus the reservation size) currently reserved for the following timeslots: 5:00pm, 5:15pm, 5:30pm, 5:45pm and 6:00pm. If any are over the value of 76, then the reservation should not be made, it should be denied. After each random reservation is made (or denied), the program should display a nicelyformatted table showing the current reservation counts for each timeslot. This displaying must be done by means of a function that takes the 2D array as a parameter. The table should look as show below on the left. Note that it indicates the number of people currently reserved for that timeslot. You can see that on Tuesday, a reservation for 12 people has been reserved starting at 5:30pm and they are estimated to be gone by 7:30pm. The smaller group of 2 people on Sunday at 5:00pm are estimated to only be there for 1 hour. The image on the right shows the results after quite a few reservations have been made many of them overlapping.

image text in transcribed

Sun Mon Tue Wed Thu Fri Sat| Sun Mon Tue Wed Thu Fri Sat| - - -- - - - - - - 4:00pm 4:15pm 4:30pm L 4:45pm L | 3 5:00pm 21 31 5:15pm 21 31 | 5:30pm 21 12 31 L 5:45pm 2 12 31 6:00pm 12 6:15pm I I 6:30pm 6:45pm 7:00pm 7:15pm 16 7:30pm 16 7:45pm 1 i 16 8:00pm 16 8:15pm 16 8:30pm 161 8:45pm 9:00pm | 21 | TILT 4:00pm | 1 | 16| 191 31 151 4:15pm | 1 | 25 19 31 21| 4:30pm 25 19 31 21 4:45pm | 25 22 15 401 5:00pm | 191 |32|52|24|40| 5:15pm 191 |41|58|21|40 5| 5:30pm 191 531 58 21 341 51 5:45pm | 471 | 53 581 211 37| 16 | 6:00pm | 45 i 28 36 21 27 16 6:15pm 451 21 441 211 32 16 6:30pm 451 21 3832|3211| 6:45pm 451 28|21|27| 30 18 11 7:00pm | 2839| 121 8 30 151 11| 7:15pm 281 68 12 8 30 10 11| 7:30pm 171 68 8 41) 5 7:45pm 76] 16 18 41| 191 i 8:00p | 141 76 16| 10| 41| 201 16| 8:15pm |26|76| 16 23 30 20 16| 8:30pm 261 760 161 23 461 201 16 8:45pm |26|37|1623| 45 32 16 9:00pm | 26| 42| 16 311 451 341 16| 16

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And Implementation

Authors: Edward Sciore

2nd Edition

3030338355, 978-3030338350

More Books

Students also viewed these Databases questions

Question

2. Do you find change a. invigorating? b. stressful? _______

Answered: 1 week ago

Question

How was their resistance overcome?

Answered: 1 week ago