c++ programming HELP!!!!?

Question by nicole: c++ programming HELP!!!!?
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
void box(int x, int xx, int y, int yy);
void box(int x, int xx, int y, int yy)
{
int xs,ys,i,j;
xs=xx-x;
ys=yy-y;
for(i=1; i>name;
getch();
clrscr();
box(5,50,9,50);
box(10,65,1,5);
gotoxy(23,3);cout<<"Who Wants to be a MILLIONAIRE?"; box(55,78,8,30); gotoxy(62,12);cout<<"LIFELINE"; gotoxy(57,15);cout<<"1. 50:50"; gotoxy(57,18);cout<<"2. Call a friend"; gotoxy(57,21);cout<<"3. Ask the audience"; gotoxy(6,10);cout<<"QUESTION 1:"; gotoxy(12,13);cout<<"Who discovered Computer?"; gotoxy(8,15);cout<<"a. Charles Darwin"; gotoxy(29,15);cout<<"b. Charles Babbage"; gotoxy(8,17);cout<<"c. Isaac Newton"; gotoxy(29,17);cout<<"d. Abraham Lincoln"; getch(); gotoxy(9,22);cout<<"Do you want to use your lifeline?"; gotoxy(13,24);cout<<"[ Y/N : ] "; cin>>ask;
if(ask==’y’)
{
gotoxy(10,28);cout<<"Choose Lifeline Number: "; cin>>life;
if(life==1)
{
gotoxy(18,31);cout<<"[ 50:50 ]"; gotoxy(8,34);cout<<"_________"; gotoxy(29,34);cout<<"c. Isaac Newton"; gotoxy(8,37);cout<<"b. Charles Babbage"; gotoxy(29,37);cout<<"_________"; getch(); } else if(life==2) { gotoxy(18,31);cout<<"[ Call a friend ]"; gotoxy(10,34);cout<<"Friend: I think it is B"; getch(); gotoxy(10,36);cout<<"You: How sure are you?"; getch(); gotoxy(10,38);cout<<"Friend: I'm 95% sure about this."; getch(); } else if(life==3) { gotoxy(18,31);cout<<"[ Ask the audience ]"; gotoxy(8,36);cout<<"(a.) 23% (b.) 52% (c.) 13% (d.) 12%"; getch(); } } else if(ask=='n') getch(); gotoxy(16,42);cout<<"Your answer is: "; cin>>ans;
if(ans==’b’)
{
gotoxy(18,45);cout<<"You're Right!"; getch(); gotoxy(16,47);cout<<"You just won ,000!!!"; getch(); gotoxy(15,49);cout<<"Get ready for the next round!"; } else { gotoxy(18,45);cout<<"Wrong!"; gotoxy(16,47);cout<<"Try again"; getch(); exit(0); } getch(); clrscr(); box(5,50,9,50); box(10,65,1,5); gotoxy(23,3);cout<<"Who Wants to be a MILLIONAIRE?"; box(55,78,8,30); gotoxy(62,12);cout<<"LIFELINE"; gotoxy(57,15);cout<<"1. 50:50"; gotoxy(57,18);cout<<"2. Call a friend"; gotoxy(57,21);cout<<"3. Ask the audience"; gotoxy(6,10);cout<<"QUESTION 2:"; gotoxy(10,13);cout<<"Folder contains...?"; gotoxy(10,15);cout<<"a. Foods"; gotoxy(28,15);cout<<"b. Animals"; gotoxy(10,17);cout<<"c. Clothes"; gotoxy(28,17);cout<<"d. Files"; getch(); gotoxy(9,22);cout<<"Do you want to use your lifeline?"; gotoxy(13,24);cout<<"[ Y/N : ] "; cin>>ask;
if(ask==’y’)
{
gotoxy(10,28);cout<<"Choose Lifeline Number: "; cin>>life;
if(life==1)
{
gotoxy(18,31);cout<<"[ 50:50 ]"; gotoxy(10,34);cout<<"a. Foods"; gotoxy(26,34);cout<<" _________"; gotoxy(10,37);cout<<" _________"; gotoxy(26,37);cout<<"d. Files"; getch(); } else if(life==2) { gotoxy(18,31);cout<<"[ Call a friend ]"; gotoxy(10,34);cout<<"Friend: I think it is D"; getch(); gotoxy(10,36);cout<<"You: How sure are you?"; getch(); gotoxy(10,38);cout<<"Friend: I'm 95% sure about this."; getch(); } else if(life==3) { gotoxy(18,31);cout<<"[ Ask the audience ]"; gotoxy(8,36);cout<<"(a.) 23% (b.) 12% (c.) 13% (d.) 52%"; getch(); } } else if(ask=='n') getch(); gotoxy(16,42);cout<<"Your answer is: "; cin>>ans;
if(ans==’d’)
{
gotoxy(18,45);cout<<"You're Right!"; getch(); gotoxy(16,47);cout<<"You just won ,000!!!"; getch(); gotoxy(15,49);cout<<"Get ready for the next round!"; } else { gotoxy(18,45);cout<<"Wrong!"; gotoxy(16,47);cout<<"Try again"; getch(); exit(0); } getch(); } Best answer:

Answer by Robert
//global variable 3 bits represent 3 lifelines
bitset<4> lifelines(15);// 4 bits all set to 1

//in the code
if(life==1 && lifelines[0]==1)
{
lifelines[0]=0;

else if(life==2 && lifelines[1]==1)
{
lifelines[1]=0;

Give your answer to this question below!

Add a Comment

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