Q&A: c++ programming.. HELP ME please..? :'(?

Question by nicole: c++ programming.. 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.? I’m using the very very old Turbo c++ version 3.0 and it requires in our school. I tried bool to eliminate the lifelines but it does not work.. Will you please try to help me and figure out how to removed lifelines after being used…? I desperately need it.. 2 days to go before the deadline and this our exam.. Thanks.. (^_^)

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(); @ ANALPROGRAMMER: Hi sir, Thanks for your help, I'm just a little bit confused about your code. I tried to run it on my turbo c++, it does not work, it said, I should have a prototype and Do i have to use integer for my lifelines like this:? int lifeline=1 ,lifeline=2, lifeline=3; and your code if(life==1 && isLife1) does not work.. I'm so sorry sir, I'm not really good about it. I'm just a beginner. :'( may you help me again sir? (^_^) Best answer:

Answer by AnalProgrammer
I would not have written your program this way. But then there are lots of different ways of doing things in computing.

Start here
cout<<"LIFELINE"; cout<<"1. 50:50"; cout<<"2. Call a friend"; cout<<"3. Ask the audience"; Make this code a function. The code will use three global boolean values to decide what to show. Then you get the lifeline number. What happens if the number entered is not 1, 2 or 3? The answer is nothing. You need to make sure that the number entered is valid. That is another function. To process input cout<<"Choose Lifeline Number: "; cin>>life;
while (!validLifeline(life)) {
cout << "Error! That lifeline is not available" << endl; cout<<"Choose Lifeline Number: "; cin>>life;
} //End while
//The lifeline is now valid.

Now to test the life variable
if(life==1 && isLife1)

Have fun.

Give your answer to this question below!

Add a Comment

Your email address will not be published. Required fields are marked *