While loop

When i enter 'n', it does not end the program.

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
  #include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
using namespace std;

int main() {

	bool game;
	

	
	do {
		char choice;
		double capacity, present, percent_used, remove, remaining_space;

		cout << "Would you like to use the capacity calculator (y,n)?" << endl;

		cin >> choice;

		if (choice == 'y') {

			cout << "How many people can be allowed in your room" << endl;

			cin >> capacity;

			cout << "How many people are currently in the room" << endl;

			cin >> present;

			if (present > capacity) {
				cout << "You have too many people in the room at this time " << endl;
				remove = present - capacity;
				cout << "You need to remove " << remove << " people in order to be at capacity" << endl;
			}

			else if (capacity > present) {

				cout << "You have a safe amount of people in this room" << endl;
				percent_used = (present / capacity) * 100;
				cout << "You are only using " << percent_used << "% " << "of the rooms capacity" << endl;
			}
		}
		else if (choice == 'n') {
			cout << "Have a nice day" << endl;
			game = false;
		}

	} while (game=true);
		
	
	system("pause");
	return 0;
}
line 49 you are using assignment operator '=' instead of comparision '=='
Topic archived. No new replies allowed.