If, Else If Statement Problems

I am having a problem using if and else if statements. I want to eliminate the goto statements used in my code, but every time I try to delete them and let the code exit the while (day = 1)loop by itself (via setting the day to 2 if the if the player survives) it always goes back inside of the while(day = 1) loop.

For example, if I removed the goto statement at the end of the process of chopping down the tree, making a sword, gathering dirt, saying no to making a house and fighting the zombie, I would get this output:

Your day code is csdnf
Press any key to continue...
You have died.
Press any key to continue...
Day 1
You wake up and find a tree. What do you do?
 Chop <c> or Leave <l>?


It stays in the while(day = 1) loop if you continue with the program using the same options (chop, sword, dirt, no house, fight), but I don't understand why because I set the integer day equal to 2 (day = 2). Again, I want to know how I can exit the while(day = 1) loop and enter the while(day = 2) loop without using the goto statement.
You are using = when you should be using ==.
Part 1 of the code:

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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#include <iostream>
#include <iomanip>
#include <string>
#include <Windows.h>
#include <sstream>

using namespace std;

int main()
{
	
	int day (1), red, blue, white, green, yellow;
	stringstream day1choices;
	
	HANDLE hConsole;
	hConsole = GetStdHandle (STD_OUTPUT_HANDLE);
	
	
	//series 1
	char tree, tool, material, house, monster_scenario;
	string result;
	int treeop, toolop, materialop, houseop, monster_scenarioop; 

	//series 2
	char activity;

	cout << "Can you survive in Minecraft? \n";
	system ("pause");

	
	//day 1
	while (day = 1){
	day1:
	for(green = 2; green < 3; green++)
	SetConsoleTextAttribute(hConsole,green);
	cout << "Day " << day << "\n";
	for(white = 7; white < 8; white++)
	SetConsoleTextAttribute(hConsole,white);
	cout << "You wake up and find a tree. What do you do? \n Chop <c> or Leave <l>? \n";
	cin >> tree;
	
	if (tree == 'c'){
		cout << "You obtain some wood and create wooden planks. \n What tool do you want to make? \n Pickaxe <p> or Sword <s>? \n";
		cin >> tool;
		
		if (tool == 'p'){
			cout << "You make a pickaxe and head off to the nearby mountain. \n What material do you collect? \n Dirt <d> or Cobblestone <c>? \n";
			cin >> material;
			
			if (material == 'c'){
				cout << "You gather some cobble and notice the sun is starting to set. \n Do you make a house? \n Yes <y> or No <n>? \n";
				cin >> house;

				if (house == 'y'){
					cout << "You make a house and are starting to feel sleepy. \n Where do you lay down at? \n Downstairs <d> or Upstairs <u>? \n";
					cin >> monster_scenario;

					//pickaxe, cobblestone, house
					if (monster_scenario == 'd'){
						for(blue = 1; blue < 2; blue++)
						SetConsoleTextAttribute(hConsole,blue);
						cout << "You survived the first night! \n";
						for(white = 7; white < 8; white++)
						SetConsoleTextAttribute(hConsole,white);
						day = 2;
						day1choices << tree << tool << material << house << monster_scenario << "\n";  
						string day1code (day1choices.str());
						cout << "Your day code is " << day1code;
						system ("pause");
						goto day2;}
					else if (monster_scenario == 'u'){
						for(blue = 1; blue < 2; blue++)
						SetConsoleTextAttribute(hConsole,blue);
						cout << "You survived your first night! \n";
						for(white = 7; white < 8; white++)
						SetConsoleTextAttribute(hConsole,white);
						day = 2;
						day1choices << tree << tool << material << house << monster_scenario << "\n"; 
						string day1code (day1choices.str());
						cout << "Your day code is " << day1code;
						system ("pause");
						goto day2;}	
				}

				else if (house == 'n'){
					cout << "You walk through the night, looking for more supplies. \n A skeleton appears and starts to fire at you \n How do you respond? \n Run away <r> or Fight Back <f>? \n";
					cin >> monster_scenario;

					//pickaxe, cobblestone, no house
					if (monster_scenario == 'f'){
						for(red = 4; red < 5; red++)
						SetConsoleTextAttribute(hConsole,red);
						cout << "You try to fight, but unfortunately the skeleton is able to block your pickaxe and \n finish you off with a blow to the chest. \n You have died. \n";
						for(white = 7; white < 8; white++)
						SetConsoleTextAttribute(hConsole,white);

						system ("pause");
						goto day1;}
					else if (monster_scenario == 'r'){
						for(red = 4; red < 5; red++)
						SetConsoleTextAttribute(hConsole,red);
						cout << "You try to run, but unfortunately the skeleton gets \n a headshot on you with one finishing blow. \n You have died. \n";
						for(white = 7; white < 8; white++)
						SetConsoleTextAttribute(hConsole,white);
						system ("pause");
						goto day1;}
				}

				
			}
			else if (material == 'd');{
				cout << "You gather some dirt and notice the sun is starting to set. \n Do you make a house? \n Yes <y> or No <n>? \n";
				cin >> house;

				if (house == 'y'){
					cout << "You make a house and are starting to feel sleepy. \n Where do you lay down at? \n Downstairs <d> or Upstairs <u>? \n";
					cin >> monster_scenario;

					//pickaxe, dirt, house
					if (monster_scenario == 'd'){
						for(red = 4; red < 5; red++)
						SetConsoleTextAttribute(hConsole,red);
						cout << "A zombie awakens you in your sleep. \n You grab your pickaxe and try to kill it \n but unfortunately the zombie doesn't die and starts to munch on your limbs. \n You have died.";
						for(white = 7; white < 8; white++)
						SetConsoleTextAttribute(hConsole,white);
						system ("pause");
						goto day1;}
					else if (monster_scenario == 'u'){
						for(blue = 1; blue < 2; blue++)
						SetConsoleTextAttribute(hConsole,blue);
						cout << "You survived your first night! \n";
						for(white = 7; white < 8; white++)
						SetConsoleTextAttribute(hConsole,white);
						day = 2;
						day1choices << tree << tool << material << house << monster_scenario << "\n"; 
						string day1code (day1choices.str());
						cout << "Your day code is " << day1code;
						system ("pause");
						goto day2;}	
				}

				else if (house == 'n'){
					cout << "You walk through the night, looking for more supplies. \n A creeper appears and quickly moves towards you. How do you respond? \n Run away <r> or Fight Back <f>? \n";
					cin >> monster_scenario;

					//pickaxe, dirt, no house
					if (monster_scenario == 'f'){
						for(red = 4; red < 5; red++)
						SetConsoleTextAttribute(hConsole,red);
						cout << "The creeper gets close enough to you to hit but this triggers its explosive reaction. You have died. \n";
						for(white = 7; white < 8; white++)
						SetConsoleTextAttribute(hConsole,white);
						system ("pause");
						goto day1;}
					else if (monster_scenario == 'r'){
						for(blue = 1; blue < 2; blue++)
						SetConsoleTextAttribute(hConsole,blue);
						cout << "You manage to get away from the creeper safely. \n, You barely surivived the night. \n";
						for(white = 7; white < 8; white++)
						SetConsoleTextAttribute(hConsole,white);
						day1choices << tree << tool << material << house << monster_scenario << "\n"; 
						string day1code (day1choices.str());
						cout << "Your day code is " << day1code;
						day = 2;
						system ("pause");
						goto day2;}
			}
		
		}
		}

		else if (tool == 's');{
			cout << "You make a sword and head off to the nearby forest. \n What material do you collect? \n Dirt <d> or Wood <w>? \n";
			cin >> material;

			if (material == 'w'){
				cout << "You gather some wood and notice the sun is starting to set. \n Do you make a house? \n Yes <y> or No <n>? \n";
				cin >> house;

				if (house == 'y'){
					cout << "You make a house and are starting to feel sleepy. \n Where do you lay down at? \n Downstairs <d> or Upstairs <u>? \n";
					cin >> monster_scenario;

					//sword, wood, house
					if (monster_scenario == 'd'){
						for(blue = 1; blue < 2; blue++)
						SetConsoleTextAttribute(hConsole,blue);
						cout << "You survived the first night! \n";
						for(white = 7; white < 8; white++)
						SetConsoleTextAttribute(hConsole,white);
						day = 2;
						day1choices << tree << tool << material << house << monster_scenario << "\n"; 
						string day1code (day1choices.str());
						cout << "Your day code is " << day1code;
						system ("pause");
						goto day2;}
					else if (monster_scenario == 'u'){
						for(blue = 1; blue < 2; blue++)
						SetConsoleTextAttribute(hConsole,blue);
						cout << "You survived your first night! \n";
						for(white = 7; white < 8; white++)
						SetConsoleTextAttribute(hConsole,white);
						day = 2;
						day1choices << tree << tool << material << house << monster_scenario << "\n"; 
						string day1code (day1choices.str());
						cout << "Your day code is " << day1code;
						system ("pause");
						goto day2;}	
				}
				
Part 2 of the code
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
else if (house == 'n'){
					cout << "You walk through the woods at night, looking for more supplies. \n A zombie appears and starts to run towards you \n How do you respond? \n Run away <r> or Fight Back <f>? \n";
					cin >> monster_scenario;

					//sword, wood, no house
					if (monster_scenario == 'f'){
						for(blue = 1; blue < 2; blue++)
						SetConsoleTextAttribute(hConsole,blue);
						cout << "You defeat the zombie and barely survive the first night! \n";
						for(white = 7; white < 8; white++)
						SetConsoleTextAttribute(hConsole,white);
						day = 2;
						day1choices << tree << tool << material << house << monster_scenario << "\n"; 
						string day1code (day1choices.str());
						cout << "Your day code is " << day1code;
						system ("pause");
						goto day2;}
					else if (monster_scenario == 'r'){
						for(red = 4; red < 5; red++)
						SetConsoleTextAttribute(hConsole,red);
						cout << "You try to run, but unfortunately the zombie gets\n close enough to you to eat your limbs off. \n You have died. \n";
						for(white = 7; white < 8; white++)
						SetConsoleTextAttribute(hConsole,white);
						system ("pause");
						goto day1;}
				}


			}
			
			else if (material == 'd'){
				cout << "You gather some dirt and notice the sun is starting to set. \n Do you make a house? \n Yes <y> or No <n>? \n";
				cin >> house;

				if (house == 'y'){
					cout << "You make a house and are starting to feel sleepy. \n Where do you lay down at? \n Downstairs <d> or Upstairs <u>? \n";
					cin >> monster_scenario;

					//sword, dirt, house
					if (monster_scenario == 'd'){
						for(blue = 1; blue < 2; blue++)
						SetConsoleTextAttribute(hConsole,blue);
						cout << "A zombie awakens you in your sleep, you manage \n to grab your sword and slay it before you die. \n You barely surivive the night. \n";
						for(white = 7; white < 8; white++)
						SetConsoleTextAttribute(hConsole,white);
						day = 2;
						day1choices << tree << tool << material << house << monster_scenario << "\n"; 
						string day1code (day1choices.str());
						cout << "Your day code is " << day1code;
						system ("pause");
						goto day2;}
					else if (monster_scenario == 'u'){
						for(blue = 1; blue < 2; blue++)
						SetConsoleTextAttribute(hConsole,blue);
						cout << "You survived your first night! \n";
						for(white = 7; white < 8; white++)
						SetConsoleTextAttribute(hConsole,white);
						day = 2;
						day1choices << tree << tool  << material << house << monster_scenario << "\n"; 
						string day1code (day1choices.str());
						cout << "Your day code is " << day1code;
						system ("pause");
						goto day2;}	
				}
				else if (house == 'n'){
					cout << "You walk through the woods at night, looking for more supplies. \n A zombie appears and starts to run towards you \n How do you respond? \n Run away <r> or Fight Back <f>? \n";
					cin >> monster_scenario;
					
					//sword, dirt, no house
					if (monster_scenario == 'f'){
						for(blue = 1; blue < 2; blue++)
						SetConsoleTextAttribute(hConsole,blue);
						cout << "You defeat the zombie and barely survive the first night! \n";
						for(white = 7; white < 8; white++)
						SetConsoleTextAttribute(hConsole,white);
						day = 2;
						day1choices << tree << tool << material << house << monster_scenario << "\n"; 
						string day1code (day1choices.str());
						cout << "Your day code is " << day1code;
						system ("pause");
						goto day2;
					}
					else if (monster_scenario == 'r'){
						for(red = 4; red < 5; red++)
						SetConsoleTextAttribute(hConsole,red);
						cout << "You try to run, but unfortunately the zombie gets \n close enough to you to eat your limbs off. \n You have died. \n";
						for(white = 7; white < 8; white++)
						SetConsoleTextAttribute(hConsole,white);
						system ("pause");
						goto day1;
						
						}
				}

			}
	}

	}


	else if (tree == 'l');{
		cout << "You have died. \n";
		system ("pause");
	}
						
		
	}
	


	
	//day 2
	while (day = 2);{
	day2:
	for(green = 2; green < 3; green++)
	SetConsoleTextAttribute(hConsole,green);
	cout << "Day " << day << "\n";
	for(white = 7; white < 8; white++)
	SetConsoleTextAttribute(hConsole,white);
	cout << "You wake up the next day, the sun is shining bright. \n What are you going to do today? \n Mine (m) or Hunt (h)? \n";
	cin >> activity;
	}
	
	system ("pause");
	return 0;
}
Sorry if I incorrectly posted this topic. I'm still a noob to C++ and the forums.
Topic archived. No new replies allowed.