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(); Best answer:

Answer by Q.Bank
Use a variable to keep track of the life line used. Then delete the life line used for the next question using this variable as simple as that.

It is your code with modifications…

#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;
lifeUsed = 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"; if( lifeUsed != 1 ) { gotoxy(57,15);cout<<"1. 50:50"; } if( lifeUsed != 2 ) {gotoxy(57,18);cout<<"2. Call a friend";} if( lifeUsed != 3 ) {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 == lifeUsed )
{
gotoxy(16,45);cout<<"Not available"; gotoxy(16,47);cout<<"Try again"; getch(); exit(0); } 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(); return 0; } Just copy and paste it. It works fine. I hope this is what your are looking after. Best wishes!

Know better? Leave your own answer in the comments!

Add a Comment

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