Simple Code Error

Hey guys Im working through a simple if else problem and it is not recognizing my "else" lines...any assistance appreciated!

#include <iostream>
using namespace std;
int main ()

{

double excess;
double too_many_people;
double max_capacity;
double attending;

cout<<"Enter maximum room capacity"<<endl;
cin>> max_capacity;
cout<<"Enter number of people attending"<<endl;
cin>> attending;
if (attending<max_capacity)
excess=max_capacity-attending;
cout<<"It is legal to hold the meeting and "<<excess<<" people may still attend"<<endl;

else if (attending==max_capacity)
cout<< "It is legal to hold the meeting"<<endl;

else if (attending>max_capacity)
too_many_people=attending-max_capacity;
cout<<"The meeting cannot be held as planned due to fire regulations because you are "<<too_many_people<<" people too many"<<endl;

return 0;
}
Last edited on
you are missing smth, think what defines the scope within a block of statments

hint: you used them for int main()
Last edited on
1
2
3
4
{
excess=max_capacity-attending;
cout<<"It is legal to hold the meeting and "<<excess<<" people may still attend"<<endl;
}


It is not clear what you want to execute as a result of the if, or the second else if, if you want the two lines following the second else if to execute as a result of that else if, place both lines within brackets as well
Topic archived. No new replies allowed.