In this lab you will practice:
Modify the provided C++ program Program6_ReserveRoom.cpp to use user-defined functions without changing the functioning of the given program. The figure on the following page is the provided program Program6_ReserveRoom.cpp.
1. In the comments on the top of the code, add your name and the current date
2. The code segment in the BLUE box is to display the menu for different rooms. A function displayMenu could be created for this part:
3. The code segment in the RED box is to request the room choice from the user. A function makeChoice could be created for this part:
4. The code segment in the GREEN box is to reserve a room according to the user's choice. A function reserveRoom could be created for this part:
5. Function calls
6. Function prototypes
Program6_ReserveRoom_YourName.cpp
#include < iostream >
using namespace std;
int main()
{
int choice;
cout << "This system is for conference room reservation\n";
//Display the menu
cout << "\n*****************************************\n";
cout << "*\t 1. Red Private Room\t\t*\n";
cout << "*\t 2. Green Board Room\t\t*\n";
cout << "*\t 3. Blue Class Room\t\t*\n";
cout << "*\t 4. Yellow Banquet Room\t\t*\n";
cout << "*\t-1. Exit\t\t\t*\n";
cout << "*****************************************\n";
//Request the choice
do {
cout << "\nPlease enter your choice: ";
cin >> choice;
} while (choice != -1 && choice != 1 && choice != 2 && choice != 3 && choice != 4);
if(choice == -1) {
cout << "\nYou have decided to exit!\n\n";
exit(0);
}
//Reserve the room according to user's choice
switch(choice) {
case 1:
cout << "\nYou like to reserve a private meeting room.\n\n";
break;
case 2:
cout << "\nYou like to reserve a room for board meeting.\n\n";
break;
case 3:
cout << "\nYou like to reserve a big classroom.\n\n";
break;
case 4:
cout << "\nYou like to reserve a luxury banquet room.\n\n";
break;
default:
cout << "\nYou should not be here!\n\n";
}
return 0;
}