Question
The fancy new French restaurant La Food is very popular for its authentic cuisine and high prices. This restaurant does not take reservations. To help
The fancy new French restaurantLa Foodis very popular for its authentic cuisine and high prices. This restaurant does not take reservations. To help improve the efficiency of their operations, the Maitre De has hired write program that simulates people waiting for tables. The goal is to determine the average amount of time people spend waiting for tables.
Your program will read in a list of event descriptions from a text file, one description per line.
- Arrival:A party has arrived to eat. Add them to the end of the list of waiting parties (a Queue) and tell them to wait at the bar (where strong drinks are served) until called. This event is described in the following format:
- At n name
- Heretis the time of arrival (in minutes past opening time),nis the number of people in the party, andnameis the name to call when the table is ready.
- Table:A table has become available; remove the party that has been waiting the longest from your list, and seat them. This event is described in the following form:
- Tt
- Heretis the time the table became available (again, in minutes past opening time),
- Quit:This is a sentinel event indicating the end of the input file. It has the following form:
- Q
When the events in the file have been processed, compute and print the average waiting time per customer. If there are still people waiting for tables, print a summary of who is still waiting.
Sample Data File
Here is a sample data file. You may use this if you like, or you can make up your own.
A 3 3 Merlin A 8 2 Arthur Pendragon T 10 A 12 2 Sir Lancelot T 15 A 17 3 The Green Knight T 20 Q Here is the corresponding output from the simulator program. The user's input appears in italics.*** Welcome to the La Food Restaurant Simulator *** Enter data file name: data.txt Please wait at the bar, party Merlin of 3 people. (time=3) Please wait at the bar, party Arthur Pendragon of 2 people. (time=8) Table for Merlin! (time=10) Please wait at the bar, party Sir Lancelot of 2 people. (time=12) Table for Arthur Pendragon! (time=15) Please wait at the bar, party The Green Knight of 3 people. (time=17) Table for Sir Lancelot! (time=20) ** Simulation Terminated ** The average waiting time was: 7.28 The following parties were never seated: party The Green Knight of 3 people Have a nice meal!
Hand In
Turn in a listing of your program, a sample run, and a printout of your data file if you did not use the one above.
Be sure to include everyone's name in the comments at the top of your program. I expect you to use the Queue interface and implementation files from class; it should not be necessary to change them in any way. If you do change them, and you're not doing the extra credit (see below), it is likely you are doing something wrong.
Extra Credit (5 points)
Modify theAcommand to include a tip/bribe for the Maitre De. The new format would then be
At n b name
wherebis the amount of the bribe, in Euros, of course. A party is then placed in line ahead of everyone who gave a lesser bribe. Two parties that bribe the same amount are placed in order of arrival.
Modify the input file to include bribes for a sample run, and print the total bribe money collected as part of the final summary.
Note:This is not trivial. Do not start this until the rest is working correctly. You will have to change some aspects of the Queue implementation to get this to work.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started