Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help with my reservation and order arrays. They aren't working at all and any help is greatly appreciated. The code is c++: void makeReservation(Reservation

Need help with my reservation and order arrays. They aren't working at all and any help is greatly appreciated. The code is c++:

void makeReservation(Reservation reservations[], int MAX_RESERVATIONS, int numReservations) { if (numReservations < MAX_RESERVATIONS) { Reservation newReservation; cout << "Enter a name for the reservation: "; cin >> ws; getline(cin, newReservation.name); cout << "Enter the number of people in the party: "; cin >> newReservation.numPeople; cout << "Enter the time for the reservation in HH:MM AM/PM: "; cin >> ws; getline(cin, newReservation.time); cout << "Please confirm the reservation: " << "Reservation Name: " << newReservation.name << " " << "Reservation Time: " << newReservation.time << " " << "Number in Party: " << newReservation.numPeople << " " << "Is this information correct [Y]es, [N]o (make changes), [C]ancel? "; char confirmChoice; cin >> confirmChoice; if (confirmChoice == 'Y' || confirmChoice == 'y') { reservations[numReservations++] = newReservation; cout << "Reservation confirmed. "; } else if(confirmChoice == 'N' || confirmChoice == 'n') { cout << "What do you want to change? 1. Name 2. Number of People 3. Time 4. Cancel "; int editChoice; cin >> editChoice; switch (editChoice){ case 1: cout << "Enter a name for the reservation: "; cin >> ws; getline(cin, newReservation.name); break; case 2: cout << "Enter the number of people in the party: "; cin >> newReservation.numPeople; break; case 3: cout << "Enter the time for the reservation in HH:MM AM/PM: "; cin >> ws; getline(cin, newReservation.time); break; case 4: return; default: cout << "Invalid choice. Please try again. "; } cout << "Please confirm the reservation: " << "Reservation Name: " << newReservation.name << " " << "Reservation Time: " << newReservation.time << " " << "Number in Party: " << newReservation.numPeople << " " << "Is this information correct [Y]es, [N]o (make changes), [C]ancel? "; char confirmChoice; cin >> confirmChoice; if (confirmChoice == 'Y' || confirmChoice == 'y'){ reservations[numReservations++] = newReservation; reservations[numReservations].isCheckedIn = false; cout << "Reservation confirmed. "; } } else if (confirmChoice == 'C' || confirmChoice == 'c'){ return; } } else { cout << "Maximum number of reservations reached. "; } } void checkInReservation(Reservation reservations[], Table tables[], Order orders[], int numReservations, int numTables, int numOrders) { if (numReservations > 0) { cout << "Choose the reservation to check in: "; for (int i = 0; i < numReservations; ++i) { if (!reservations[i].isCheckedIn) { cout << i + 1 << ": " << reservations[i].name << " - " << reservations[i].time << ", " << reservations[i].numPeople << " people "; }1 } int choice; cin >> choice; if (choice >= 1 && choice <= numReservations && !reservations[choice - 1].isCheckedIn) { cout << "Please assign a table: "; for (int i = 0; i < numTables; ++i) { if (tables[i].isFree && reservations[choice - 1].numPeople <= tables[i].size) { cout << i + 1 << ": Table " << tables[i].tableNumber << " - " << tables[i].size << " people "; } } int tableChoice; cin >> tableChoice; if (tableChoice >= 1 && tableChoice <= numTables && tables[tableChoice - 1].isFree) { tables[tableChoice - 1].isFree = false; tables[tableChoice - 1].currentOccupancy = reservations[choice - 1].numPeople; tables[tableChoice - 1].needsOrder = true; reservations[choice - 1].time += " - Table " + to_string(tables[tableChoice - 1].tableNumber); reservations[choice - 1].isCheckedIn = true; cout << "Reservation checked in successfully. "; } else { cout << "Invalid table choice or table is already occupied. "; } } else { cout << "Invalid reservation choice or reservation is already checked in. "; } } else { cout << "No reservations available to check in. "; } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions

Question

How many moles of water are there in 1.000 L? How many molecules?

Answered: 1 week ago