Game Program

Base on the rule, there will be 3lifelines that you may use. But you can only use each of it once. How can I make those lifelines be used only once?

this is my code:
(questions are for trial only)


#include <iostream>
#include <cstdlib>
#include <conio.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;


int main(int argc, char** argv)
{
char ans1,ans2,dec;
char name[10];
int x,y,z;
x= 1000;
y = x * 2;
z = 0;
int op,life,ch,num;

cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ "<<endl;
cout<<"$ $ "<<endl;
cout<<"$-------------------Who Wants To Be A Millionaire------------------$ "<<endl;
cout<<"$ $ "<<endl;
cout<<"$ $ "<<endl;
cout<<"$--------------------------Programmed By---------------------------$ "<<endl;
cout<<"$ $ "<<endl;
cout<<"$ $ "<<endl;
cout<<"$ $ "<<endl;
cout<<"$ $ "<<endl;
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ "<<endl<<endl;
cout<<"_____________________________________________________________________"<<endl<<endl;
cout<<"Welcome to Who wants to be a Millionaire!"<<endl;
cout<<"Enter your Name: ";
cin>>name;

cout<<"Okay "<<name<<", Here's the mechanics: ";
cout<<"There is 15 questions and each question have\ntheir corresponding amount. You have 3 lifelines that may save you."<<endl<<endl;
po:

cout<<"***************************************************************************"<<endl;
cout<<"Lifeline no.1: Ask the Audience - You will ask the opinion of the audience."<<endl;
cout<<"Lifeline no.2: 50:50 - The two right answers will remain."<<endl;
cout<<"Lifeline no.3: Call a Friend - You may call a friend to help you\n\t to the said question."<<endl;
cout<<"***************************************************************************"<<endl<<endl;

cout<<"So, Mr. "<<name<<" Let's start?"<<endl;
po1:
cout<<"Press 'Y' to start: "<<endl;
cin>>dec;
system("cls");

if(dec == 'y' && 'Y')
{
goto po2;
}
else if(dec != 'y' && 'Y')
{
cout<<"Just press 'Y' whenever your ready :)"<<endl;
goto po1;
}


po2:
cout<<"For P1000:\n"<<endl;
cout<<"What is the Capital of the Philippines?\n";
cout<<"a.)Manila \t b.)Recto\nc.)Quezon City \t d.)Quiapo\n"<<endl;
cout<<"Want to use your Lifeline?"<<endl;
cout<<"[1]Yes \t[2]No"<<endl;
cin>>ch;

if(ch == 1)
{
goto po3;
}
else if(ch == 2)
{
goto po4;
}

po3:
cout<<"***************************************************************************"<<endl;
cout<<"[1]: Ask the Audience - You will ask the opinion of the audience."<<endl;
cout<<"[2]: 50:50 - The two right answers will remain."<<endl;
cout<<"[3]: Call a Friend - You may call a friend to help you\n\t to the said question."<<endl;
cout<<"***************************************************************************"<<endl;
cin>>life;
if(life == 1)
{
cout<<"a.)******************"<<endl;
cout<<"b.)*****"<<endl;
cout<<"c.)*************"<<endl;
cout<<"d.)********"<<endl;
}
else if(life == 2)
{
cout<<"a.)Manila \t b.)------\nc.)------ \t d.)Quiapo"<<endl;
}
else if(life == 3)
{
cout<<"Enter phone number: "<<endl;
cin>>num;
cout<<"CALLING . . ."<<endl;
getch();
cout<<"Friend: Hello? "<< name <<" What's up dude?"<<"Need Help?"<<endl;
getch();
cout<<name<<": Yes dude. What is the Capital of the Philippines?"<<endl;
getch();
cout<<"Friend: I think it's Manila!"<<endl;
getch();
cout<<name<<": How sure are you?"<<endl;
getch();
cout<<"Friend: I'm 100% sure about this."<<endl;
getch();
cout<<name<<": Okay thanks!"<<endl;
getch();
cout<<"Friend: Okay! Keep Rockin' the Free world!"<<endl<<endl;

}

po4:
cout<<"Choose Your Answer: "<<endl;
cin>>ans1;
cout<<"Is that your final answer?"<<endl;
cout<<"[Y]Yes, That's my final answer \t [N]Not yet"<<endl;
cin>>dec;

if(dec == 'y' && 'Y')
{
goto po5;
}
else if(dec != 'y' && 'Y')
{
system("cls");
goto po2;
}

po5:
switch(ans1)
{
case 'a' :
cout<<"\nCongrats! You answered right!"<<endl;
break;
case 'b' :
cout<<"\nYou answered wrong! You Lose!"<<endl;
break;
case 'c' :
cout<<"\nYou answered wrong! You Lose!"<<endl;
break;
case 'd' :
cout<<"\nYou answered wrong! You Lose!"<<endl;
break;
default :
cout<<"\nInvalid Input";
}
switch(ans1)
{
case 'a':
cout<<"You just won: P"<<x<<endl;
break;
case 'b':
cout<<"I'm sorry, you will take home: P"<<z<<endl;
break;
case 'c':
cout<<"I'm sorry, you will take home: P"<<z<<endl;
break;
case 'd':
cout<<"I'm sorry, you will take home: P"<<z<<endl;
break;
default :
system("cls");
cout<<"Invalid input! Choose between the choices!\n"<<endl;
goto po2;
}
if(ans1 == 'a')
{
cout<<"Proceed to the next Question? Or You will now go home with P"<<x<<"\n[1]Proceed \t[2]Go Home"<<endl;
cin>>op;
}
else if(ans1 != 'a')
{
cout<<"Thank you for playing! :)"<<endl;
return 0;
}

switch(op)
{
case 1:
cout<<"_____________________________________________________________________"<<endl<<endl;
break;
case 2:
cout<<"Alright! "<<name<<" You'll take home P"<<x<<"\nThank you for playing! :)"<<endl;
return 0;
break;
default :
cout<<"Invalid Input!"<<endl;
}
cout<<"What is the color of an Apple?"<<endl;
cout<<"a.)Black \t b.)Rainbow \nc.)Red \t\t d.)Colorless"<<endl;
cout<<"\nChoose Your Answer: "<<endl;
cin>>ans2;
switch(ans2)
{
case 'a':
cout<<"\nYou answered wrong! You Lose!"<<endl;
break;
case 'b':
cout<<"\nYou answered wrong! You Lose!"<<endl;
break;
case 'c':
cout<<"\nCongrats! You answered right!"<<endl;
break;
case 'd':
cout<<"\nYou answered wrong! You Lose!"<<endl;
break;
default :
cout<<"\nInvalid Input";
}
switch(ans2)
{
case 'a':
cout<<"I'm sorry, you will take home: P"<<z<<endl;
break;
case 'b':
cout<<"I'm sorry, you will take home: P"<<z<<endl;
break;
case 'c':
cout<<"You have now: P"<<y<<endl;
break;
case 'd':
cout<<"I'm sorry, you will take home: P"<<z<<endl;
break;
default :
cout<<" "<<endl;
}
if(ans2 == 'c')
{
cout<<"Proceed to the next Question? Or You will now go home with P"<<y<<"\n[1]Proceed \t[2]Go Home"<<endl;
cin>>op;
}
else if(ans2 != 'c')
{
cout<<"Thank you for playing! :)"<<endl;
return 0;
}
switch(op)
{
case 1:
cout<<"_____________________________________________________________________"<<endl<<endl;
cout<<"Question no.3:"<<endl;
break;
case 2:
cout<<"Alright! You'll take home P"<<y<<"\nThank you for playing! :)"<<endl;
return 0;
break;
}





system("pause");


return 0;
}
I'll help you when you can give me an idea what you think is wrong and use code tags.
Sir, So far i think there is no wrong with my code. It's just i don't know how to make the lifeline be useable for only once.
How to use a code tags sir? I'm sorry, I'm just new here :(
button looks like
<>
I added lifeline to my codes, and i end up to this:

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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
#include <iostream>
#include <cstdlib>
#include <conio.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;


int main(int argc, char** argv) 
{
	char ans1,ans2,dec;
    char name[10];
	int x,y,z;
	x= 1000;
	y = x * 2;
	z = 0;
	int op,life,ch,num;
	int lifeline=3, lifeline1=1, lifeline2=1, lifeline3=1;
	cout<<"Welcome to Who wants to be a Millionaire!"<<endl;
	cout<<"Enter your Name: ";
	cin>>name;
	
	cout<<"Okay "<<name<<", Here's the mechanics: ";
	cout<<"There is 15 questions and each question have\ntheir corresponding amount. You have 3 lifelines that may save you."<<endl<<endl;
	po:
	
	cout<<"***************************************************************************"<<endl;
	cout<<"Lifeline no.1: Ask the Audience - You will ask the opinion of the audience."<<endl;
	cout<<"Lifeline no.2: 50:50 - The two right answers will remain."<<endl;
	cout<<"Lifeline no.3: Call a Friend - You may call a friend to help you\n\t       to the said question."<<endl;
	cout<<"***************************************************************************"<<endl<<endl;
	
	cout<<"So, Mr. "<<name<<" Let's start?"<<endl;
	po1:
	cout<<"Press 'Y' to start: "<<endl;
	cin>>dec;
	system("cls");
	
	if(dec == 'y' | 'Y')
		{
			goto po2;
		}
	else if(dec != 'y' | 'Y')
		{
		cout<<"Just press 'Y' whenever your ready "<<endl;
		goto po1;
		}	
	
	
	po2:
	cout<<"For P1000:\n"<<endl;
	cout<<"What is the Capital of the Philippines?\n";
	cout<<"a.)Manila \t b.)Recto\nc.)Quezon City \t d.)Quiapo\n"<<endl;
	cout<<"Want to use your Lifeline?"<<endl;
	cout<<"[1]Yes \t[2]No"<<endl;
	cin>>ch;
	
	if(ch == 1)
	{
		goto po3;
	}
	else if(ch == 2)
	{
		goto po4;
	}
	
	po3:
        if (lifeline>0)
        {
	    cout<<"***************************************************************************"<<endl;
	    if (lifeline1=1)
        {
                        cout<<"[1]: Ask the Audience - You will ask the opinion of the audience."<<endl;
        }
	    if (lifeline2=1)
        {
                        cout<<"[2]: 50:50 - The two right answers will remain."<<endl;
        }
	    if (lifeline3=1)
        {
                        cout<<"[3]: Call a Friend - You may call a friend to help you\n\t       to the said question."<<endl;
        }
	    cout<<"***************************************************************************"<<endl;
	    cin>>life;
        }
    
	if(lifeline1 == 1)
		{
		cout<<"a.)******************"<<endl;
		cout<<"b.)*****"<<endl;
		cout<<"c.)*************"<<endl;
		cout<<"d.)********"<<endl;
		lifeline1-=1;
		lifeline-=1;
		}
	else if(lifeline2 == 2)
		{
		cout<<"a.)Manila \t b.)------\nc.)------ \t d.)Quiapo"<<endl;
		lifeline2-=1;
		lifeline-=1;
		}
	else if(lifeline3 == 3)
		{
		cout<<"Enter phone number: "<<endl;
		cin>>num;
		cout<<"CALLING . . ."<<endl;
		getch();
		cout<<"Friend: Hello? "<< name <<" What's up dude?"<<"Need Help?"<<endl;
		getch();
		cout<<name<<": Yes dude. What is the Capital of the Philippines?"<<endl;
		getch();
		cout<<"Friend: I think it's Manila!"<<endl;
		getch();
		cout<<name<<": How sure are you?"<<endl;
		getch();
		cout<<"Friend: I'm 100% sure about this."<<endl;
		getch();
		cout<<name<<": Okay thanks!"<<endl;
		getch();
		cout<<"Friend: Okay! Keep Rockin' the Free world!"<<endl<<endl;
		lifeline3-=1;
		lifeline-=1;
		
		}
		
	po4:
	cout<<"Choose Your Answer: "<<endl;
	cin>>ans1;
	cout<<"Is that your final answer?"<<endl;
	cout<<"[Y]Yes, That's my final answer \t [N]Not yet"<<endl;
	cin>>dec;
	
	if(dec == 'y' && 'Y')
	{
		goto po5;	
	}
	else if(dec != 'y' && 'Y')
	{
		system("cls");
		goto po2;	
	}
	
	po5:
	switch(ans1)
	{	
		case 'a'  :
			cout<<"\nCongrats! You answered right!"<<endl;
			break;
		case 'b' :
			cout<<"\nYou answered wrong! You Lose!"<<endl;
			break;
		case 'c' :
			cout<<"\nYou answered wrong! You Lose!"<<endl;
			break;
		case 'd' :
			cout<<"\nYou answered wrong! You Lose!"<<endl;
			break;
	default :
		cout<<"\nInvalid Input";			
	}
	switch(ans1)
	{
		case 'a':
			cout<<"You just won: P"<<x<<endl;
			break;
		case 'b':
			cout<<"I'm sorry, you will take home: P"<<z<<endl;
			break;
		case 'c':
			cout<<"I'm sorry, you will take home: P"<<z<<endl;
			break;
		case 'd':
			cout<<"I'm sorry, you will take home: P"<<z<<endl;
			break;
	default :
		system("cls");
		cout<<"Invalid input! Choose between the choices!\n"<<endl;
		goto po2;
	}
	if(ans1 == 'a')
		{
		cout<<"Proceed to the next Question? Or You will now go home with P"<<x<<"\n[1]Proceed \t[2]Go Home"<<endl;
		cin>>op;
		}
	else if(ans1 != 'a')
		{
		cout<<"Thank you for playing! "<<endl;
		return 0;
		}
		
	switch(op)
	{
		case 1:
				cout<<"_____________________________________________________________________"<<endl<<endl;
				break;
		case 2:
				cout<<"Alright! "<<name<<" You'll take home P"<<x<<"\nThank you for playing! "<<endl;
				return 0;
				break;
	default :
		cout<<"Invalid Input!"<<endl;
	}
	
	po6:
	cout<<"What is the color of an Apple?"<<endl;
	cout<<"a.)Black \t b.)Rainbow \nc.)Red \t\t d.)Colorless"<<endl;
	cout<<"Want to use your Lifeline?"<<endl;
	cout<<"[1]Yes \t[2]No"<<endl;
	cin>>ch;
	
	if(ch == 1)
	{
		goto po7;
	}
	else if(ch == 2)
	{
		goto po8;
	}
	
	po7:
        if (lifeline>0)
        {
	    cout<<"***************************************************************************"<<endl;
	    if (lifeline1=1)
        {
                        cout<<"[1]: Ask the Audience - You will ask the opinion of the audience."<<endl;
        }
	    if (lifeline2=1)
        {
                        cout<<"[2]: 50:50 - The two right answers will remain."<<endl;
        }
	    if (lifeline3=1)
        {
                        cout<<"[3]: Call a Friend - You may call a friend to help you\n\t       to the said question."<<endl;
        }
	    cout<<"***************************************************************************"<<endl;
	    cin>>life;
        }
	
	if(lifeline1 == 1)
		{
		cout<<"a.)*****"<<endl;
		cout<<"b.)***********"<<endl;
		cout<<"c.)*************"<<endl;
		cout<<"d.)**"<<endl;
		}
	else if(lifeline2 == 2)
		{
		cout<<"a.)------ \t b.)Rainbow\nc.)Red \t d.)------"<<endl;
		}
	else if(lifeline3 == 3)
		{
		cout<<"Enter phone number: "<<endl;
		cin>>num;
		cout<<"CALLING . . ."<<endl;
		getch();
		cout<<"Friend: Hello? "<< name <<" What's up dude?"<<"Need Help?"<<endl;
		getch();
		cout<<name<<": Yes dude. What is the Capital of the Philippines?"<<endl;
		getch();
		cout<<"Friend: I think it's Red!"<<endl;
		getch();
		cout<<name<<": How sure are you?"<<endl;
		getch();
		cout<<"Friend: I'm 89% sure about this."<<endl;
		getch();
		cout<<name<<": Okay thanks!"<<endl;
		getch();
		cout<<"Friend: Okay! Keep Rockin' the Free world!"<<endl<<endl;
		
	   }	
	
	
	po8:
	cout<<"Choose Your Answer: "<<endl;
	cin>>ans2;
	cout<<"Is that your final answer?"<<endl;
	cout<<"[Y]Yes, That's my final answer \t [N]Not yet"<<endl;
	cin>>dec;
	
	if(dec == 'y' && 'Y')
	{
		goto po5;	
	}
	else if(dec != 'y' && 'Y')
	{
		system("cls");
		goto po6;	
	}
	
	po9:
	switch(ans2)
	{
		case 'a':
			cout<<"\nYou answered wrong! You Lose!"<<endl;
			break;
		case 'b':
			cout<<"\nYou answered wrong! You Lose!"<<endl;
			break;
		case 'c':
			cout<<"\nCongrats! You answered right!"<<endl;
			break;
		case 'd':
			cout<<"\nYou answered wrong! You Lose!"<<endl;
			break;
	default :
		cout<<"\nInvalid Input";
	}	
	switch(ans2)
	{
		case 'a':
			cout<<"I'm sorry, you will take home: P"<<z<<endl;
			break;
		case 'b':
			cout<<"I'm sorry, you will take home: P"<<z<<endl;
			break;
		case 'c':
			cout<<"You have now: P"<<y<<endl;
			break;
		case 'd':
			cout<<"I'm sorry, you will take home: P"<<z<<endl;
			break;
	default :
		cout<<" "<<endl;
	}
	
	
	
	
	
	if(ans2 == 'c')
		{
		cout<<"Proceed to the next Question? Or You will now go home with P"<<y<<"\n[1]Proceed \t[2]Go Home"<<endl;
		cin>>op;
		}
	else if(ans2 != 'c')
		{
		cout<<"Thank you for playing! "<<endl;
		return 0;
		}
		
	}
	
	system("pause");	
	
	
	return 0;
}
The Lifeline reduction didn't work :((
You should learn about functions. Your code is difficult to read because everything is written linearly with a lot of repetitive code.

You never actually change the number of lifelines. When you display lifelines, you use '=', which is assignment, rather than '=='. That means you set them to 1 every time.
Topic archived. No new replies allowed.