Jump to content

HEY WAZZUP I need help with my program I was able to input lower case letters and suddenly after modifying my functions I does not work anymore so I need help If you can help me with the lifelines cuz it has problems so please help me

 

 


#include <iostream>
#include <stdlib.h>
#include <limits>
#include <cctype>

using namespace std;

int lifelineCount=0;
int mistakeCount=4;
//int lifelineAnswer = 1;
int life = 3;
int lifeCrowd = 1;
int lifeHalf=1;
int lifeCall=1;




void CheckAnswer(char correctAnswer, int question)
{
int i=0;

	while (i<3) 
	{
		char answer;
		std::cin >> answer;

		
	

		if (answer == correctAnswer)
		{
			std::cout << "Correct!\n";
			break; 	
		}
		else if (answer == '1')
		{
		
	cout<<"================================================================="<<endl;
	cout<<"[1]-Ask The Audience - You will get the audience opinion."<<endl;
	cout<<"[2]-50:50 the two right answes will remain"<<endl;
	cout<<"[3]-Call a Friend - get a friend to help you out"<<endl;
	cout<<"================================================================="<<endl;
	cin>>life;
		if (life == 1){
	 //Audience
	if (lifeCrowd > 0){
       if (question ==1) {
     	
	 cout<<"A:********"<<endl;
     cout<<"B:***************"<<endl;
     cout<<"C:******"<<endl;
     cout<<"D:*"<<endl;
     lifeCrowd--;
 }

 else if  (question ==2) {
   	
   	
    
     	
	 
	 cout<<"A:***********"<<endl;
     cout<<"B:********"<<endl;
     cout<<"C:*********"<<endl;
     cout<<"D:******"<<endl;
     lifeCrowd--;
 }

 else if  (question ==3) { 
     	
	 
	 cout<<"A:*********"<<endl;
     cout<<"B:********"<<endl;
     cout<<"C:*********"<<endl;
     cout<<"D:***********"<<endl;
     lifeCrowd--;
 }

 else if  (question ==4) { 
     	
	 
	 cout<<"A:*********"<<endl;
     cout<<"B:********"<<endl;
     cout<<"C:***********"<<endl;
     cout<<"D:******"<<endl;
     lifeCrowd--;
 }

 else if  (question ==5) { 
     	
	 
	 cout<<"A:*****"<<endl;
     cout<<"B:****"<<endl;
     cout<<"C:******"<<endl;
     cout<<"D:*******"<<endl;
     lifeCrowd--;
 }

 else if  (question ==6) { 
     	
	 
	 cout<<"A:*******"<<endl;
     cout<<"B:************"<<endl;
     cout<<"C:*********"<<endl;
     cout<<"D:***********"<<endl;
     lifeCrowd--;
 }

 else if  (question ==7) { 
     	
	 
	 cout<<"A:*********"<<endl;
     cout<<"B:***********"<<endl;
     cout<<"C:*********"<<endl;
     cout<<"D:******"<<endl;
     lifeCrowd--;
 }

 else if  (question ==8) { 
     	
	 
	 cout<<"A:***********"<<endl;
     cout<<"B:********"<<endl;
     cout<<"C:*********"<<endl;
     cout<<"D:******"<<endl;
     lifeCrowd--;
 }

 else if  (question ==9) { 
 
 
     	
	 
	 cout<<"A:**"<<endl;
     cout<<"B:*"<<endl;
     cout<<"C:****"<<endl;
     cout<<"D:***********"<<endl;
     lifeCrowd--;
 }
 
 
 else if  (question ==10) { 
     	
	 
	 cout<<"A:******"<<endl;
     cout<<"B:********"<<endl;
     cout<<"C:*********"<<endl;
     cout<<"D:******"<<endl;
     lifeCrowd--;
 } 

}
	 
	 

	 
	else if (life == 2 ){
	 
	 
	 //50:50
	 
	 if(lifeHalf > 0){
	 
	if  (question ==1) { 
     	
	 
	 cout<<"B-Angela Merkel"<<endl;
     cout<<"D-Hanz Zimmerman"<<endl;
     lifeHalf--;
}

else if (question ==2) {
	cout<<"A-Antonio Sallieri"<<endl;
	cout<<"B-Johann Pachelbel"<<endl;
}

else if (question ==3) {
	cout<<"B-Gamma Processing Unit"<<endl;
	cout<<"D-Graphics Processing Unit"<<endl;
}

else if (question ==4) {
	cout<<"B-Bohemian Rhapsody"<<endl;
	cout<<"C-Green Book"<<endl;
}

else if (question ==5) {
	cout<<"B-Delta"<<endl;
	cout<<"D-KLM"<<endl;
}

else if (question ==6) {
	cout<<"Buggati Chiron"<<endl;
	cout<<"Bugatti Veyron"<<endl;
}

else if (question ==7) {
	cout<<"B-Queen Victoria"<<endl;
	cout<<"D-Queen Elizabeth"<<endl;
}

else if (question ==8) {
	cout<<"B-Ben Simmons"<<endl;
	cout<<"C-Magic Johnson"<<endl;
}

else if (question ==9) {
	cout<<"B-John Adams"<<endl;
	cout<<"D-Robert Heft"<<endl;
}

else if (question ==10) {
	cout<<"C-Antonov 225 "<<endl;
	cout<<"D-Antonov 124"<<endl;
}
}
    
 }
 //CALL A FRIEND VERY NICE PROGRAM
   else if (life ==3){
   	
         if (question ==1){
   	cout<<"CALLING"<<endl;
   	cout<<"Friend:Hello"<<endl;
   	cout<<"You:Hey can you help me out"<<endl;
   	cout<<"Friend:Sure"<<endl;
   	cout<<"You:Who is the Chancellor of Germany here are the choices"<<endl;
   	
	   
cout<<"A-Wilhem II"<<endl;
cout<<"B-Angela Merkel"<<endl;
cout<<"C-Franz Hamburg"<<endl;
cout<<"D-Hanz Zimmerman"<<endl;
cout<<"Want To use a lifeline?"<<endl;

   	cout<<"Friend:I think it's Angela Merkel not that sure"<<endl;
   	cout<<"You:Ok thanks for the input"<<endl;
   	cout<<"Friend:No problem goodluck"<<endl;
   }

   	else if (question ==2){
   	cout<<"CALLING"<<endl;
   	cout<<"Friend:Hello"<<endl;
   	cout<<"You:Hey can you help me out"<<endl;
   	cout<<"Friend:Sure"<<endl;
   	cout<<"You:Who is the competitor of Mozart Here are the choices"<<endl;
   	
   	cout<<"Who is the competitor Wolfgang Amadeus Mozart?"<<endl;
cout<<"A-Antonio Sallieri"<<endl;
cout<<"B-Ludwig Beethoven"<<endl;
cout<<"C-Johann Pachelbel"<<endl;
cout<<"D-Johann Sallieri"<<endl;
   	
   	cout<<"Friend:Hmmmmmmmmm it's Antonio Sallieri"<<endl;
   	cout<<"You:Ok thanks for the input"<<endl;
   	cout<<"Friend:No problem goodluck"
   	<<endl;
   }
   
    else if (question ==3){
   	cout<<"CALLING"<<endl;
   	cout<<"Friend:Hello"<<endl;
   	cout<<"You:Hey can you help me out"<<endl;
   	cout<<"Friend:Sure"<<endl;
   	cout<<"You:What's the meaning of GPU"<<endl;
   	
   	cout<<"In Computer Hardware what does GPU mean?"<<endl;
cout<<"A-Game Processing Unit"<<endl;
cout<<"B-Gamma Processing Unit"<<endl;
cout<<"C-Grayscale Processing Unit"<<endl;
cout<<"D-Graphics Processing Unit"<<endl;
   	
   	cout<<"Friend:It's Graphics Processing Unit'"<<endl;
   	cout<<"You:Ok thanks for the input"<<endl;
   	cout<<"Friend:No problem goodluck"
   	<<endl;
   }
   	
   	else if (question ==4){
   	cout<<"CALLING"<<endl;
   	cout<<"Friend:Hello"<<endl;
   	cout<<"You:Hey can you help me out"<<endl;
   	cout<<"Friend:Sure"<<endl;
   	cout<<"You:What Movie won the 2018 oscar's here are the choices"<<endl;
   	

cout<<"A-The Favourite"<<endl;
cout<<"B-Bohemian Rhapsody"<<endl;
cout<<"C-Green Book"<<endl;
cout<<"D-Shape Of Water"<<endl;

   	cout<<"Friend:oohhh that's hard I don't really know i think it's Bohemian Rhapsody"<<endl;
   	cout<<"You:Ok thanks for the input"<<endl;
   	cout<<"Friend:No problem goodluck"
   	<<endl;
   }
   
    else if (question ==5){
   	cout<<"CALLING"<<endl;
   	cout<<"Friend:Hello"<<endl;
   	cout<<"You:Hey can you help me out"<<endl;
   	cout<<"Friend:Sure"<<endl;
   	cout<<"You:What is the oldest airline that is still operating here are the choices"<<endl;
   	
   	cout<<"A-Qantas"<<endl;
cout<<"B-Delta"<<endl;
cout<<"C-Avianca"<<endl;
cout<<"D-KLM"<<endl;

   	cout<<"Friend:KLM for sure"<<endl;
   	cout<<"You:Ok thanks for the input"<<endl;
   	cout<<"Friend:No problem goodluck"
   	<<endl;
   }
   
    else if (question ==6){
   	cout<<"CALLING"<<endl;
   	cout<<"Friend:Hello"<<endl;
   	cout<<"You:Hey can you help me out"<<endl;
   	cout<<"Friend:Sure"<<endl;
   	cout<<"You:What is the fastest production car here are the choices"<<endl;
   	  	
cout<<"A-Koenisegg Regera"<<endl;
cout<<"B-Buggati Chiron"<<endl;
cout<<"C-Mclaren Senna"<<endl;
cout<<"D-Buggati Veyron"<<endl;

   	cout<<"Friend:hmmmm not quite good with this one probably Buggati Veyron"<<endl;
   	cout<<"You:Ok thanks for the input"<<endl;
   	cout<<"Friend:No problem goodluck"
   	<<endl;
   }
   
    else if (question ==7){
   	cout<<"CALLING"<<endl;
   	cout<<"Friend:Hello"<<endl;
   	cout<<"You:Hey can you help me out"<<endl;
   	cout<<"Friend:Sure"<<endl;
   	cout<<"You:Who is the second longest reigning monarch here are the choices"<<endl;
   	
   	cout<<"A-Alexander the Great"<<endl;
cout<<"B-Queen Victoria"<<endl;
cout<<"C-King Henry"<<endl;
cout<<"D-Queen Elizabeth"<<endl;

   	cout<<"Friend:I think Queen Victoria not to keen if it is right "<<endl;
   	cout<<"You:Ok thanks for the input"<<endl;
   	cout<<"Friend:No problem goodluck"
   	<<endl;
   }
   
    else if (question ==8){
   	cout<<"CALLING"<<endl;
   	cout<<"Friend:Hello"<<endl;
   	cout<<"You:Hey can you help me out"<<endl;
   	cout<<"Friend:Sure"<<endl;
   	cout<<"You:Who is the tallest point guard of all time here are the choices"<<endl;
   	
   	cout<<"A-Wardell Stephen Curry"<<endl;
cout<<"B-Ben Simmons"<<endl;
cout<<"C-Magic Johnson"<<endl;
cout<<"D-Betsy R"<<endl;
   	
   	cout<<"Friend:oohhh that's hard I don't really know i think it's Ben Simmons"<<endl;
   	cout<<"You:Ok thanks for the input"<<endl;
   	cout<<"Friend:No problem goodluck"
   	<<endl;
   }
   
    else if (question ==9){
   	cout<<"CALLING"<<endl;
   	cout<<"Friend:Hello"<<endl;
   	cout<<"You:Hey can you help me out"<<endl;
   	cout<<"Friend:Sure"<<endl;
   	cout<<"You:Who designed the first US flag here are the choices"<<endl;
   	
   	cout<<"A-Jane Doe"<<endl;
cout<<"B-John Adams"<<endl;
cout<<"C-Abraham Lincoln"<<endl;
cout<<"D-Robert Heft"<<endl;
   	
   	cout<<"Friend:not to keen on history i think it's Robert Heft'"<<endl;
   	cout<<"You:Ok thanks for the input"<<endl;
   	cout<<"Friend:No problem goodluck"
   	<<endl;
   }
   
    else if (question ==10){
   	cout<<"CALLING"<<endl;
   	cout<<"Friend:Hello"<<endl;
   	cout<<"You:Hey can you help me out"<<endl;
   	cout<<"Friend:Sure"<<endl;
   	cout<<"You:What is the largest cargo aircraft here are the choices"<<endl;
   	
   	cout<<"A-C-5 Galaxy:"<<endl;
cout<<"B-Boeing 747-8F"<<endl;
cout<<"C-Antonov 225 Myirya"<<endl;
cout<<"D-Antonov 124"<<endl;
   	
   	cout<<"Friend:for sure it's an Antonov but not sure what model tho'"<<endl;
   	cout<<"You:Ok thanks for the input"<<endl;
   	cout<<"Friend:No problem goodluck"
   	<<endl;
   }	  
}

		
		else 
		{
		cout << "Wrong\n";
		} 
		i++;
	}
	}
}
}
main(){

int turn=3;
int Incorrect=3;
int ch;
int life=3;








/*	do{
	//if(answer==Incorrect);

	{
		
		
		turn--;
			}
   
}while (turn !=0);

	{ */
		//INTRODUCTION
		
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
cout<<"$$                                                                         $$"<<endl;
cout<<"$$-------------------TO WHO WANTS TO BE A MILLIONARE-----------------------$$"<<endl;
cout<<"$$                                                                         $$"<<endl;
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
system("pause");
system("cls");
    
    
    
    
    
    
    
    

	   //rules
		system("pause");
		cout<<"RULES"<<endl;
		
		cout<<"1.DO NOT UNDER ANY CIRCUMSTANCE CHANGE ANY CODE"<<endl;
		cout<<"2.YOU HAVE 3 LIFELINES CALL A FRIEND,50-50 and Audience Opinion"<<endl;
		cout<<"3.NO CHEATING"<<endl <<endl <<endl;
		cout<<"4.ALL ANSWERS MUST BE IN CAPS" <<endl;
		cout<<"Winner takes $1,000,000";
		cout<<"WITHOUT FURTHER A DO WHO WANT TO BE A MILLIONARE?"<<endl<<endl;
		cout<<
		system("pause");
		system("cls");
		
		
		
		
		
		//who want's to be a millionare
		cout<<"WHO"<<endl;
		cout<<"WANT'S"<<endl;
		cout<<"TO"<<endl;
		cout<<"BE"<<endl;
		cout<<"A"<<endl;
		cout<<"MILLIONARE"<<endl;
		
		
		system("pause");
        system("cls");
		
		
		
	//QUESION
//question 1
std::cout<<"Who is the Current Chancellor of Germany"<<endl;



cout<<"A-Wilhem II"<<endl;
cout<<"B-Angela Merkel"<<endl;
cout<<"C-Franz Hamburg"<<endl;
cout<<"D-Hanz Zimmerman"<<endl;
cout<<"Want To use a lifeline?"<<endl;
cout<<"[1]Yes\t[2]No"<<endl;
CheckAnswer('B', 1);
system("pause");
system("cls");







//QUESTION 2
cout<<"Who is the competitor Wolfgang Amadeus Mozart?"<<endl;
cout<<"A-Antonio Sallieri"<<endl;
cout<<"B-Ludwig Beethoven"<<endl;
cout<<"C-Johann Pachelbel"<<endl;
cout<<"D-Johann Sallieri"<<endl;
cout<<"Want To use a lifeline?"<<endl;
cout<<"[1]Yes\t[2]No"<<endl;
CheckAnswer('A', 2);
system("pause");
system("cls");











//QUESTION 3
cout<<"In Computer Hardware what does GPU mean?"<<endl;
cout<<"A-Game Processing Unit"<<endl;
cout<<"B-Gamma Processing Unit"<<endl;
cout<<"C-Grayscale Processing Unit"<<endl;
cout<<"D-Graphics Processing Unit"<<endl;
cout<<"Want To use a lifeline?"<<endl;
cout<<"[1]Yes\t[2]No"<<endl;
CheckAnswer('D',3);
system("pause");
system("cls");




//QUESTION 4
cout<<"In the 2018 Oscar's What Movie won BEST PICTURE'"<<endl;
cout<<"A-The Favourite"<<endl;
cout<<"B-Bohemian Rhapsody"<<endl;
cout<<"C-Green Book"<<endl;
cout<<"D-Shape Of Water"<<endl;
cout<<"Want To use a lifeline?"<<endl;
cout<<"[1]Yes\t[2]No"<<endl;
CheckAnswer('C',4);
system("cls");





//QUESTION 5
cout<<"As of now what airline is the oldest"<<endl;
cout<<"A-Qantas"<<endl;
cout<<"B-Delta"<<endl;
cout<<"C-Avianca"<<endl;
cout<<"D-KLM"<<endl;
cout<<"Want To use a lifeline?"<<endl;
cout<<"[1]Yes\t[2]No"<<endl;
CheckAnswer('D',5);
system("pause");
system("cls");





//QUESTION 6
 
  
cout<<"Currently What Car is the fastest production car"<<endl;
cout<<"A-Koenisegg Regera"<<endl;
cout<<"B-Buggati Chiron"<<endl;
cout<<"C-Mclaren Senna"<<endl;
cout<<"D-Buggati Veyron"<<endl;
cout<<"[1]Yes\t[2]No"<<endl;
cout<<"Want To use a lifeline?"<<endl;
cout<<"[1]Yes\t[2]No"<<endl;
CheckAnswer('B',6);
system("pause");
system("cls");





//QUESTION 7
cout<<"Who is the second longest reigning monarch in the UK?"<<endl;
cout<<"A-Alexander the Great"<<endl;
cout<<"B-Queen Victoria"<<endl;
cout<<"C-King Henry"<<endl;
cout<<"D-Queen Elizabeth"<<endl;
cout<<"Want To use a lifeline?"<<endl;
cout<<"[1]Yes\t[2]No"<<endl;
CheckAnswer('B',7);
system("pause");
system("cls");


//QUESTION 8
cout<<"Who is the tallest pointguard of all time?"<<endl;
cout<<"A-Wardell Stephen Curry"<<endl;
cout<<"B-Ben Simmons"<<endl;
cout<<"C-Magic Johnson"<<endl;
cout<<"D-Betsy R"<<endl;
cout<<"Want To use a lifeline?"<<endl;
cout<<"[1]Yes\t[2]No"<<endl;
CheckAnswer('B',8);
system("pause");
system("cls");




//QUESTION 9
cout<<"Who designed the first U.S flag?";
cout<<"A-Jane Doe"<<endl;
cout<<"B-John Adams"<<endl;
cout<<"C-Abraham Lincoln"<<endl;
cout<<"D-Robert Heft"<<endl;
CheckAnswer('D',9);
system("pause");
system("cls");




//QUESTION 10
cout<<"What is the Largest Cargo Aircraft in the world?"<<endl;
cout<<"A-C-5 Galaxy:"<<endl;
cout<<"B-Boeing 747-8F"<<endl;
cout<<"C-Antonov 225 Myirya"<<endl;
cout<<"D-Antonov 124"<<endl;
cout<<"Want To use a lifeline?"<<endl;
cout<<"[1]Yes\t[2]No"<<endl;
CheckAnswer('C',10);
system("pause");
system("cls");



















	system("pause");
}

 

ASTRAY NOIR

CPU

Ryzen 5 3600

Cooler

Corsair H100I PRO

RAM

PNY XLR-8 EPIC-X DDR4-3200 CL16 32GB

GPU

ASUS ROG RTX 2070

STORAGE

SAMSUNG 850 EVO, 2xSEAGATE BARRACUDA PRO 1TB,A2000 1TB

Case

NZXT H500 

PSU

Enermax Revolution DF 650W

MONITOR

MSI MAG272,LG 22MP68BQ,DELL D2015H

PERIPHIRALS

Ducky One 2 (HORIZON) || Glorious Model O- Pink || G305 || Razer Nari Essential || HyperX Cloud II

 

 

Link to comment
https://linustechtips.com/topic/1051736-help-me-plz/
Share on other sites

Link to post
Share on other sites

You forgot the call to "toupper" to convert the character entered by the user to uppercase before comparing.

 

You should attempt to break your program into smaller, more logical pieces so it becomes easier to follow. There might be some logic errors in the checkanswer function but the function has grown too large to be manageable. Start by making 3 separate functions for ask the audience, 50/50 and call a friend. Then have yet more functions to handle each question in stead of a long list of if/else's.

Link to comment
https://linustechtips.com/topic/1051736-help-me-plz/#findComment-12456592
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×