I need to repeat this program, im thinking some kind of loop but im not sure how.
cout << "Enter maximum room capacity: ";
cin >> max;
cout << "Enter number of people attending the meeting: ";
cin >> numpeople;
cout << "*****************************************" << endl;
cout << "Room capacity is " << max << endl;
cout << "Number of people attending the meeting is " << numpeople << endl;
cout << "*****************************************" << endl;
if(max<numpeople){
cout << "The meeting cannot be held as planned due to fire regulations" << endl;
cout << numpeople - max << " must be excluded in order to meet the fire regulations." << endl;
}
else{
cout << "It is legal to hold the meeting." << endl;
cout << max - numpeople << " more people may legally attend." << endl;
}
cout << "*****************************************" << endl;
cout << "Do you want to repeat calculations for another meeting?" << endl;
cout << "Enter y to repeat and any other key to end this program: ";
obviously I need the program to repeat if a 'y' is entered and close if anything else is, but im not sure how to do this.
do
{
cout << "Enter maximum room capacity: ";
cin >> max;
cout << "Enter number of people attending the meeting: ";
cin >> numpeople;
cout << "*****************************************" << endl;
cout << "Room capacity is " << max << endl;
cout << "Number of people attending the meeting is " << numpeople << endl;
cout << "*****************************************" << endl;
if(max<numpeople){
cout << "The meeting cannot be held as planned due to fire regulations" << endl;
cout << numpeople - max << " must be excluded in order to meet the fire regulations." << endl;
}
else{
cout << "It is legal to hold the meeting." << endl;
cout << max - numpeople << " more people may legally attend." << endl;
}
cout << "*****************************************" << endl;
cout << "Do you want to repeat calculations for another meeting?" << endl;
cout << "Enter y to repeat and any other key to end this program: ";
cin>> repeat;
}while(repeat=='y');