Trouble Processing Code

Ok so this is my prompt for my program and I'm having a bit trouble displaying and computing.
"Read RoomCapacity from the keyboard
Read PeopleAttending from the keyboard
If PeopleAttending <= RoomCapacity Then
Display “It is legal to hold the meeting”
 Compute AdditionalPeople
 Display AdditionalPeople “ may legally attend”
Else
Display “The meeting cannot be held”
Compute NumberOfPeopleToBeExcluded
Display NumberOfPeopleToBeExcluded “ cannot attend”"

This is the code I have so far... it may not be much but I need help..




#include <iostream>
#include <iomanip>

using namespace std;

int main(int argc, const char * argv[])
{


int People_Attending;
double Room_Capacity = 0.0;


cout << "Room Capacity:100\n";
cout << "People Attending:";
cin >> People_Attending;


if (Room_Capacity <= 100)

{
cout << "It is legal to hold the meeting"<< endl;

}
else

{
cout << "The meeting cannot be held"<< endl;


}





return 0;
}


This is what you're starting with.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>

using namespace std;

int main(int argc, const char * argv[])
{
  int People_Attending;
  double Room_Capacity = 0.0;

  cout << "Room Capacity:100\n";
  cout << "People Attending:";
  cin >> People_Attending;

  if (Room_Capacity <= 100)
  {
    cout << "It is legal to hold the meeting"<< endl;
  }
  else
  {
    cout << "The meeting cannot be held"<< endl;
  }

  return 0;
}

What's missing? Well, you have a variable for capacity, but you're still hard coding 100 through the program. Let's replace 100 with the variable.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>

using namespace std;

int main(int argc, const char * argv[])
{
  int People_Attending = 0;
  int Room_Capacity = 0;

  cout << "Room Capacity:" << Room_Capacity << endl;
  cout << "People Attending:";
  cin >> People_Attending;

  if (Room_Capacity <= Room_Capacity)
  {
    cout << "It is legal to hold the meeting"<< endl;
  }
  else
  {
    cout << "The meeting cannot be held"<< endl;
  }

  return 0;
}

Ok, we now use Room_Capacity instead of hard coding 100. I've also declared it as int rather than double.

Now all we need to do is read in Room_Capacity.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>

using namespace std;

int main(int argc, const char * argv[])
{
  int People_Attending = 0;
  int Room_Capacity = 0;

  cout << "Room Capacity:";
  cin >> Room_Capacity;

  cout << "Room Capacity:" << Room_Capacity << endl;
  cout << "People Attending:";
  cin >> People_Attending;

  if (Room_Capacity <= Room_Capacity)
  {
    cout << "It is legal to hold the meeting"<< endl;
  }
  else
  {
    cout << "The meeting cannot be held"<< endl;
  }

  return 0;
}
Is there any reason as to why you are comparing Room_Capacity to itself? Shouldn't you be comparing it with People_Attending?
Shouldn't you be comparing it with People_Attending?
That's right, I overlooked that.
Ok, Room capacity is 100. and if it is over 100 (eg. 101) I have to have a code to compute the amount over 100 and for the additional people "may legally attend".
I need assistance with codes to compute additional and excluded people.
the prompt is below.
VVVVVVV

"If PeopleAttending <= RoomCapacity Then
Display “It is legal to hold the meeting”
 Compute AdditionalPeople
 Display AdditionalPeople “ may legally attend”
Else
Display “The meeting cannot be held”
Compute NumberOfPeopleToBeExcluded
Display NumberOfPeopleToBeExcluded “ cannot attend”



#include <iostream>

using namespace std;

int main(int argc, const char * argv[])
{
int People_Attending = 0;
int Room_Capacity = 100;



cout << "Room Capacity:" << Room_Capacity << endl;
cout << "People Attending:";
cin >> People_Attending;

if (People_Attending <= Room_Capacity)
{
cout << "It is legal to hold the meeting"<< endl;
}
else
{
cout << "The meeting cannot be held"<< endl;
}

return 0;
}
Topic archived. No new replies allowed.