Question
Restaurant Reservation System Your job is to create a reservation system for a restaurant. The restaurant has 20 tables. Here is the functionality required for
Restaurant Reservation System
Your job is to create a reservation system for a restaurant. The restaurant has 20 tables. Here is the functionality required for this system (you may want to display a menu and let user choose options 1 to 4, make sure to put your program in a loop so program does not exit until user chooses menu 0):
1- Reserve a Table User needs to input the table number (Tables are numbered from 0 to 19). If the table is not available (reserved), inform the user that the selected table is not available. If the table is available, then ask for the name (name is a single word, no space) and mark the table as reserved. 2- Clear Reservation User needs to input the table number (Tables are numbered from 0 to 19). If the table is not reserved, inform the user that the selected table is already available (nothing to clear). If the table is reserved, mark it as available. That table is no longer reserved. 3- Report Prints out the state of each table. Each table is printed on a separate line -- so your report will print out 20 rows. If reserved, it will print out the name on the reservation next to the table number. If available, it should print out "available". 0- Exit Program. I would recommend either:
a) keeping two arrays (parallel arrays!), both are size 20, one of type boolean (true/false -- reserved/available) and the other one of type string (name on reservation if reserved, blank otherwise).
b) keeping a single array of size 20 of type string. At the beginning of the program, set all the tables to "AVAILABLE". As tables get reserved, set the table array item as the name on the reservation. If the value on a table is "AVAILABLE" then the table is available (not reserved) otherwise, the table is reserved and the value is the name on the reservation.
Hints
Here some hints on this week's assignment on Restaurant Reservation System.
For this assignment, you need one array of size 20 -- because we have 20 tables. Let's call this array "tables":
string tables [20];
notice the data type -- it is string. Make sure to include #include at the beginning of your program (right after including iostream) so that string data type will be available to you.
For each table in tables, if the string value is empty (""), then the table is available (not reserved), otherwise, the table is reserved and the value is the name of the person who reserved the table. So at the beginning of your program (right after declaring the array variable), make sure to initialize tables array so that all tables are available:
for(int i=0; i < 20; i++) { tables[i] = ""; }
Assume table numbers go from 0 to 19. Now if you want to check if table #2 is available:
if (tables [2] == "") { cout << "Table 2 is available" << endl; } else { cout << "Table 2 is reserved to " << tables [2] << endl; }
If you want to make table 3 available:
tables [3] = "";
if you want to reserve table 3 with name Ali:
tables [3] = "Ali";
Hope this helps a little bit.
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