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