c++ program.. HELP ME!!! please.. :'(?

Question by nicole: c++ program.. HELP ME!!! please.. :'(?
Hi! I need help to my c++ program. I created a program that is much like the “Who wants to be a Millionaire” television show. It has questions and the right answers and three lifelines. How can I possibly do eliminate a lifeline after being used.?

this is the program I created so far:

#include
#include
#include

char name[50];
char ans;
char ask;
int life;
int main()
{
clrscr();
cout<<"Your Name: "; cin>>name;
getch();
clrscr();
cout<<"Who Wants to be a MILLIONAIRE?"; cout<<"LIFELINE"; cout<<"1. 50:50"; cout<<"2. Call a friend"; cout<<"3. Ask the audience"; cout<<"QUESTION 1:"; cout<<"Who discovered Computer?"; cout<<"a. Charles Darwin"; cout<<"b. Charles Babbage"; cout<<"c. Isaac Newton"; cout<<"d. Abraham Lincoln"; getch(); cout<<"Do you want to use your lifeline?"; cout<<"[ Y/N : ] "; cin>>ask;
if(ask==’y’)
{
cout<<"Choose Lifeline Number: "; cin>>life;
if(life==1)
{
cout<<"[ 50:50 ]"; cout<<"_________"; cout<<"c. Isaac Newton"; cout<<"b. Charles Babbage"; cout<<"_________"; getch(); } else if(life==2) { cout<<"[ Call a friend ]"; cout<<"Friend: I think it is B"; getch(); cout<<"You: How sure are you?"; getch(); cout<<"Friend: I'm 95% sure about this."; getch(); } else if(life==3) { cout<<"[ Ask the audience ]"; cout<<"(a.) 23% (b.) 52% (c.) 13% (d.) 12%"; getch(); } } else if(ask=='n') getch(); cout<<"Your answer is: "; cin>>ans;
if(ans==’b’)
{
cout<<"You're Right!"; getch(); cout<<"You just won ,000!!!"; getch(); cout<<"Get ready for the next round!"; } else { cout<<"Wrong!"; cout<<"Try again"; getch(); exit(0); } getch(); clrscr(); cout<<"Who Wants to be a MILLIONAIRE?"; cout<<"LIFELINE"; cout<<"1. 50:50"; cout<<"2. Call a friend"; cout<<"3. Ask the audience"; cout<<"QUESTION 2:"; cout<<"Folder contains...?"; cout<<"a. Foods"; cout<<"b. Animals"; cout<<"c. Clothes"; cout<<"d. Files"; getch(); cout<<"Do you want to use your lifeline?"; cout<<"[ Y/N : ] "; cin>>ask;
if(ask==’y’)
{
cout<<"Choose Lifeline Number: "; cin>>life;
if(life==1)
{
cout<<"[ 50:50 ]"; cout<<"a. Foods"; cout<<" _________"; cout<<" _________"; cout<<"d. Files"; getch(); } else if(life==2) { cout<<"[ Call a friend ]"; cout<<"Friend: I think it is D"; getch(); cout<<"You: How sure are you?"; getch(); cout<<"Friend: I'm 95% sure about this."; getch(); } else if(life==3) { cout<<"[ Ask the audience ]"; cout<<"(a.) 23% (b.) 12% (c.) 13% (d.) 52%"; getch(); } } else if(ask=='n') getch(); cout<<"Your answer is: "; cin>>ans;
if(ans==’d’)
{
cout<<"You're Right!"; getch(); cout<<"You just won ,000!!!"; getch(); cout<<"Get ready for the next round!"; } else { cout<<"Wrong!"; cout<<"Try again"; getch(); exit(0); } getch(); } Best answer:

Answer by Michael G
Declare three bools, lifeOneUsed,lifeTwoUsed,lifeThreeUsed (bool lifeOneUsed,lifeTwoUsed,lifeThreeUsed;).
Set them to false. (lifeOneUsed=false;lifeTwoUsed=false;lifeThreeUsed=false;)
Then, when you detect what lifeline is used, set that lifeline to true.
Example using lifeline one:
if(life==1)
{ lifeOneUsed=true;
// rest of code here

Then after round one use the code: (example for lifeline one)
if(life==1 & lifeOneUsed=false)
{lifeOneUsed=true;//rest of code

What do you think? Answer below!

Add a Comment

Your email address will not be published.