SHARE
HELP

To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

# Absolute C++

Authors:
Walter Savitch ,kenrick Mock
Exercise:
Programming Projects
Chapter:
C++ Basics
Edition:
5
ISBN:
9780132846813
Question:
5
 Previous Next

### Question

Write a program that determines whether a meeting room is in violation of fire law regulations regarding the maximum room capacity. The program will read in the maximum room capacity and the number of people to attend the meeting. If the number of people is less than or equal to the maximum room capacity, the program announces that it is legal to hold the meeting and tells how many additional people may legally attend. If the number of people exceeds the maximum room capacity, the program announces that the meeting cannot be held as planned due to fire regulations and tells how many people must be excluded in order to meet the fire regulations.

``````//C++ header file section
#include <iostream>
using namespace std;
int main ()
{
//Variables
int numOfPeople;
int capacityOfRoom;
char userChoice ;

//Use do-while to repeat the input unitl user choice is not entered'y'
do
{
//Read input as the maximum room capacity
// and the number of people to attend
//the meeting
cout << "Enter the maximum room capacity: ";
cin >> capacityOfRoom;
cout << "Enter the number of people to attend the meeting: ";
cin >> numOfPeople;
/*If the number of people is less than or equal to the maximum
room capacity, the program announces that it is legal to
hold the meeting and tells how many additional
people may legally attend. */
if(numOfPeople <= capacityOfRoom)
cout << "You can hold the meeting legally!";
/*If the number of people exceeds the maximum room capacity,
the program announces that the meeting cannot be held as
planned due to fire regulations and tells how many people
must be excluded in order to meet the fire regulations
*/
else if (numOfPeople > capacityOfRoom)
{
cout <<"Warning! you can not hold the meeting."
<<"But if you still want to hold"
<<"the meeting you have to exclude: "
<< (numOfPeople - capacityOfRoom) << " guest(s)..";
}
cout << endl << "Do you want to continue again the program? y/n:  ";
cin >> userChoice;
cout << endl << endl;
}
while ( userChoice =='y' || userChoice == 'Y');
cout << "\nExit program...THANK YOU\n\n";
return 0;
} ``````

Output Result:

``````Enter the maximum room capacity: 500
Enter the number of people to attend the meeting: 400
You can hold the meeting legally!
Do you want to continue again the program? y/n:  y

Enter the maximum room capacity: 200
Enter the number of people to attend the meeting: 200
You can hold the meeting legally!
Do you want to continue again the program? y/n:  y

Enter the maximum room capacity: 300
Enter the number of people to attend the meeting: 500
Warning! you can not hold the meeting. But if you still want to hold the meeting you have to exclude: 200 guest(s)..

Do you want to continue again the program? y/n:  n

Exit program...THANK YOU ``````

### Discussions

Post the discussion to improve the above solution.