Repeat a program?

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.

Thanks
I would use a do loop. this is how your code will look like.FYI use code for code next time you post.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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');


Topic archived. No new replies allowed.