Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

URGENT : Can someone help me edit this code so that the names for the Private Ro

ID: 3755781 • Letter: U

Question

URGENT : Can someone help me edit this code so that the names for the Private Room reservations have a ( * ) marked at the end.

For example : John Smith*

Here is my code.

// ConsoleApplication13.cpp : Defines the entry point for the console application.

//

#include<iostream>

#include<string>

#include<fstream>

using namespace std;

int mainMenu();

int tableMenu();

int privateRoom();

int main()

{

string table[20];

char s[20];

int ch;

int n;

string name;

for (int i = 0; i < 20; i++)

table[i] = "AVAILABLE";

do

{

int choice1, choice2, choice3;

bool cont = true;

while (true)

{

a:

choice1 = mainMenu();

switch (choice1)

{

case 1:

cont = true;

while (cont)

{

cout << " You are in Table reservation menu" << endl;

choice2 = tableMenu();

switch (choice2)

{

case 1:

cout << " You are in View reservation " << endl;

cout << "Enter table number: ";

cin >> n;

if (table[n] == "AVAILABLE")

{

cout << "Table is Available ";

}

else

{

table[n] = "NOT AVAILABLE";

cout << "Not available ";

}

break;

case 2:

cout << " You are in Table reservation menu" <<

endl;

cout << "Enter Which Table You want to reserve: ";

cin >> n;

if (table[n] == "AVAILABLE")

{

cout <<

"Table is AVAILABLE, please enter your full name: ";

cin.ignore();

cin.getline(s,20);

table[n] = s;

ofstream file;

file.open("xyz.txt", ios_base::app);

cout << file.is_open();

file << s;

file << " reserved table ";

file << n<<" ";

file.close();

}

else

{

cout << "Table is already reserved ";

}

break;

case 3:

cout << "Enter table number: ";

cin >> n;

if (table[n] == "AVAILABLE")

{

cout <<

"Table is Available, nothing to clear ";

}

else

{

table[n] = "AVAILABLE";

cout << "Cleared ";

}

break;

case 4:

cout << " You are in Search for any reservation " <<

endl;

cout << "Enter table number: ";

cin >> n;

if (table[n] == "NOT AVAILABLE")

{

cout << "Table is Available for reservation ";

}

else

{

table[n] = "AVAILABLE";

cout << "Table is not available for reservation ";

}

break;

case 5:

cout <<

"------------------------------REPORT------------------------------- ";

for (int i = 0; i < 20; i++)

cout << "Table " << i << " : " << table[i] << endl;

break;

case 6:

goto a;

break;

}

}

break;

case 2:

cont = true;

while (cont)

{

cout << " You are in private room reservation menu" <<

endl;

choice2 = tableMenu();

switch (choice2)

{

case 1:

cout << " You are in View reservation " << endl;

cout << "Enter table number: ";

cin >> n;

if (table[n] == "AVAILABLE")

{

cout << "Table is Available ";

}

else

{

table[n] = "NOT AVAILABLE";

cout << "Not available ";

}

break;

case 2:

cout << " You are in Table reservation menu" <<

endl;

cout << "Enter Which Table You want to reserve: ";

cin >> n;

if (table[n] == "AVAILABLE")

{

cout << "Table is AVAILABLE, please enter your full name: ";

cin.ignore();

cin.getline(s,20);

table[n] = s;

fstream file;

file.open("xyz.txt", ios_base::app);

file << s << " reserved private table " << n;

file.close();

}

else

{

cout << "Table is already reserved ";

}

break;

case 3:

cout << "Enter table number: ";

cin >> n;

if (table[n] == "AVAILABLE")

{

cout <<

"Table is Available, nothing to clear ";

}

else

{

table[n] = "AVAILABLE";

cout << "Cleared ";

}

break;

case 4:

cout << " You are in Search for any reservation " <<

endl;

cout << "Enter table number: ";

cin >> n;

if (table[n] == "NOT AVAILABLE")

{

cout << "Table is Available for reservation ";

}

else

{

table[n] = "AVAILABLE";

cout << "Table is not available for reservation ";

}

break;

case 5:

cout <<

"------------------------------REPORT------------------------------- ";

for (int i = 0; i < 20; i++)

cout << "Table " << i << " : " << table[i] << endl;

break;

case 6:

goto a;

break;

}

}

break;

case 3:

exit(0);

break;

}

}

break;

return 0;

} while (ch != 0);

}

int

mainMenu()

{

int cho;

cout << " 1. Table Reservation." << endl;

cout << "2. Private room Reservation." << endl;

cout << "3. Exit" << endl;

cout << "Make your choice (1 to 3) :";

cin >> cho;

return cho;

}

int tableMenu()

{

int cho;

cout << " 1. View reservation." << endl;

cout << "2. Add reservation." << endl;

cout << "3. Cancel reservation." << endl;

cout << "4. Search for reservation." << endl;

cout << "5. Review reservation." << endl;

cout << "6. Back to main menu." << endl;

cout << "Make your choice (1 to 6) :";

cin >> cho;

return cho;

}

int

privateRoom()

{

int cho;

cout << " 1. View reservation." << endl;

cout << "2. Add reservation." << endl;

cout << "3. Cancel reservation." << endl;

cout << "4. Search for reservation." << endl;

cout << "5. Review reservation." << endl;

cout << "6. Back to main menu." << endl;

cout << "Make your choice (1 to 6) :";

cin >> cho;

return cho;

}

Explanation / Answer

#include<iostream>

#include<string>

#include<fstream>

using namespace std;

int mainMenu();

int tableMenu();

int privateRoom();

int main()

{

string table[20];

char s[20];

int ch;

int n;

string name;

for (int i = 0; i < 20; i++)

table[i] = "AVAILABLE";

do

{

int choice1, choice2, choice3;

bool cont = true;

while (true)

{

a:

choice1 = mainMenu();

switch (choice1)

{

case 1:

cont = true;

while (cont)

{

cout << " You are in Table reservation menu" << endl;

choice2 = tableMenu();

switch (choice2)

{

case 1:

cout << " You are in View reservation " << endl;

cout << "Enter table number: ";

cin >> n;

if (table[n] == "AVAILABLE")

{

cout << "Table is Available ";

}

else

{

table[n] = "NOT AVAILABLE";

cout << "Not available ";

}

break;

case 2:

cout << " You are in Table reservation menu" <<

endl;

cout << "Enter Which Table You want to reserve: ";

cin >> n;

if (table[n] == "AVAILABLE")

{

cout <<

"Table is AVAILABLE, please enter your full name: ";

cin.ignore();

cin.getline(s,20);

table[n] = s;

ofstream file;

file.open("xyz.txt", ios_base::app);

cout << file.is_open();

file << s;

file << " reserved table ";

file << n<<" ";

file.close();

}

else

{

cout << "Table is already reserved ";

}

break;

case 3:

cout << "Enter table number: ";

cin >> n;

if (table[n] == "AVAILABLE")

{

cout <<

"Table is Available, nothing to clear ";

}

else

{

table[n] = "AVAILABLE";

cout << "Cleared ";

}

break;

case 4:

cout << " You are in Search for any reservation " <<

endl;

cout << "Enter table number: ";

cin >> n;

if (table[n] == "NOT AVAILABLE")

{

cout << "Table is Available for reservation ";

}

else

{

table[n] = "AVAILABLE";

cout << "Table is not available for reservation ";

}

break;

case 5:

cout <<

"------------------------------REPORT------------------------------- ";

for (int i = 0; i < 20; i++)

cout << "Table " << i << " : " << table[i] << endl;

break;

case 6:

goto a;

break;

}

}

break;

case 2:

cont = true;

while (cont)

{

cout << " You are in private room reservation menu" <<

endl;

choice2 = tableMenu();

switch (choice2)

{

case 1:

cout << " You are in View reservation " << endl;

cout << "Enter table number: ";

cin >> n;

if (table[n] == "AVAILABLE")

{

cout << "Table is Available ";

}

else

{

table[n] = "NOT AVAILABLE";

cout << "Not available ";

}

break;

case 2:

cout << " You are in Table reservation menu" <<

endl;

cout << "Enter Which Table You want to reserve: ";

cin >> n;

if (table[n] == "AVAILABLE")

{

cout << "Table is AVAILABLE, please enter your full name: ";

cin.ignore();

cin.getline(s,20);

table[n] = s+"*";

fstream file;

file.open("xyz.txt", ios_base::app);

file << s+"*" << " reserved private table " << n;

file.close();

}

else

{

cout << "Table is already reserved ";

}

break;

case 3:

cout << "Enter table number: ";

cin >> n;

if (table[n] == "AVAILABLE")

{

cout <<

"Table is Available, nothing to clear ";

}

else

{

table[n] = "AVAILABLE";

cout << "Cleared ";

}

break;

case 4:

cout << " You are in Search for any reservation " <<

endl;

cout << "Enter table number: ";

cin >> n;

if (table[n] == "NOT AVAILABLE")

{

cout << "Table is Available for reservation ";

}

else

{

table[n] = "AVAILABLE";

cout << "Table is not available for reservation ";

}

break;

case 5:

cout <<

"------------------------------REPORT------------------------------- ";

for (int i = 0; i < 20; i++)

cout << "Table " << i << " : " << table[i] << endl;

break;

case 6:

goto a;

break;

}

}

break;

case 3:

exit(0);

break;

}

}

break;

return 0;

} while (ch != 0);

}

int

mainMenu()

{

int cho;

cout << " 1. Table Reservation." << endl;

cout << "2. Private room Reservation." << endl;

cout << "3. Exit" << endl;

cout << "Make your choice (1 to 3) :";

cin >> cho;

return cho;

}

int tableMenu()

{

int cho;

cout << " 1. View reservation." << endl;

cout << "2. Add reservation." << endl;

cout << "3. Cancel reservation." << endl;

cout << "4. Search for reservation." << endl;

cout << "5. Review reservation." << endl;

cout << "6. Back to main menu." << endl;

cout << "Make your choice (1 to 6) :";

cin >> cho;

return cho;

}

int

privateRoom()

{

int cho;

cout << " 1. View reservation." << endl;

cout << "2. Add reservation." << endl;

cout << "3. Cancel reservation." << endl;

cout << "4. Search for reservation." << endl;

cout << "5. Review reservation." << endl;

cout << "6. Back to main menu." << endl;

cout << "Make your choice (1 to 6) :";

cin >> cho;

return cho;

}