SlideShare une entreprise Scribd logo
1  sur  19
#include <iostream>
#include <string>
using namespace std;
int Guess;
int Total;
class Question
{
private:
string Question_Text;
string Answer_1;
string Answer_2;
string Answer_3;
string Answer_4;
int Correct_Answer;
int Question_Score;
public:
void setValues (string,string,string,string,string, int, int);
void askQuestion();
};
int main()
{
cout<<"Welcome to the Quiz Master"<<endl;
cout<<"Synonym & Antonym"<<endl;
cout<<"INSRUCTION"<<endl;
cout<<"*********************************************
**********"<<endl;
cout<<"* Choose one of the possible out of four. *"<<endl;
cout<<"* You have to get at least 70 or above *"<<endl;
cout<<"* to pass the quiz. *"<<endl;
cout<<"*********************************************
**********"<<endl;
cout<<"Press ENTER to start the quiz"<<endl;
cin.get();
string Name;
cout<<"What is your name?"<<endl;
cin>> Name;
string Respond;
cout<<"Are you ready to take the quiz, "<<Name<<"?
Yes/No?"<<endl;
cin>>Respond;
if (Respond == "yes")
{
cout<<endl;
cout<<"Good Luck!"<<endl;
cout<<endl;
}
else if (Respond == "no")
{
cout<<"Goodbye!"<<endl;
return 0;
}
Question q1;
Question q2;
Question q3;
Question q4;
Question q5;
Question q6;
Question q7;
Question q8;
Question q9;
Question q10;
q1.setValues("what is the synonym of stupid?",
"dumb",
"smart",
"clever",
"genious",
1,
10);
q2.setValues("what is the synonym of beautiful? ",
"helpful",
"happy",
"ugly",
"pretty",
4,
10);
q3.setValues("what is the synonym of stretch?",
"fetch",
"intense",
"expand",
"tease",
3,
10);
q4.setValues("what is the synonym of happy?",
"negative",
"impossible",
"joyful",
"hateful",
3,
10);
q5.setValues("what is the synonym of good?",
"dream",
"excellent",
"recycle",
"mean",
2,
10);
q6.setValues("what is the antonym of dark?",
"bright",
"green",
"dim",
"cloudy",
1,
10);
q7.setValues("what is the antonym of sucessful? ",
"stright",
"pass",
"fullfil",
"fail",
4,
10);
q8.setValues("what is the antonym of tight?",
"tiny",
"small",
"loose",
"stress",
3,
10);
q9.setValues("what is the antonym of advantage? ",
"benefit",
"disadvantage",
"favor",
"improvement",
2,
10);
q10.setValues("what is the antonym of strong?",
"hard",
"soft",
"weak",
"power",
3,
10);
q1.askQuestion();
q2.askQuestion();
q3.askQuestion();
q4.askQuestion();
q5.askQuestion();
q6.askQuestion();
q7.askQuestion();
q8.askQuestion();
q9.askQuestion();
q10.askQuestion();
cout<<"Your total score is"<<Total<<"out of 100"<<endl;
cout<<endl;
if(Total >= 70)
{
cout<<"Great, you passed the quiz!"<<endl;
cout<<endl;
cout<<"Congratulation"<<endl;}
else
{
cout<<"Sorry, you failed the quiz"<<endl;
cout<<"Better luck next time!"<<endl;
}
return 0;
}
void Question::setValues(string q, string a1, string a2, string
a3, string a4, int ca, int qs)
{
Question_Text = q;
Answer_1 = a1;
Answer_2 = a2;
Answer_3 = a3;
Answer_4 = a4;
Correct_Answer = ca;
Question_Score = qs;
}
void Question:: askQuestion()
{
cout<<endl;
cout<< Question_Text <<endl;
cout<<"1."<<Answer_1<<endl;
cout<<"2."<<Answer_2<<endl;
cout<<"3."<<Answer_3<<endl;
cout<<"4."<<Answer_4<<endl;
cout<<endl;
cout<<"what is your answer?"<<endl;
cin>>Guess;
if (Guess == Correct_Answer)
{
cout<<endl;
cout<<"Correct!"<<endl;
Total = Total + Question_Score;
}
else
{
cout<<endl;
cout<<"Incorect!"<<endl;
cout<<"The correct answer is "<<
Correct_Answer<<"."<<endl;
}
}
Please give me some comments as well as the clues of how this
program works. Thank you
Solution
Program Execution starts from the main method.The program
will wait till the user presses enter button.And asks for the
name, and asks for whether he is ready to take the quiz.if the
user enters “yes” It will start the quiz by wishing you good
luck.If the user enters “no” the program will terminate by
displaying a message good bye.
If the user enters “yes” then the program will create multiple
instances to the class “Question”.
Question q1;
Question q2;
Question q3;
Question q4;
Question q5;
Question q6;
Question q7;
Question q8;
Question q9;
Question q10;
After that using the instances it will call the function of the
class “Question” .
It will call the function by passing the parameters which will set
the values to the class variables.
After that it will call another function which will displays the
Questions And waiting for the user to enter the option.
If the answer is correct it will calculate the score by adding the
score to the total.If the user entered answer is wrong it displays
the correct answer.
Finally if the total score of the quiz is greater than or equal to
70.then it displays a message that the user passed the exam.
If he got less score than 70 it displays the message that he
failed in the exam.
_____________________________________________________
____________________________________
Quiz.cpp
#include <iostream>
#include <string>
using namespace std;
//Declaring Global Variables which we can use any where in the
program.
int Guess;
int Total;
// Creating the class
class Question
{
private:
//declaring variables.
string Question_Text;
string Answer_1;
string Answer_2;
string Answer_3;
string Answer_4;
int Correct_Answer;
int Question_Score;
public:
//Functions.
void setValues (string,string,string,string,string, int, int);
void askQuestion();
};
int main()
{
//Displaying messages.
cout<<"Welcome to the Quiz Master"<<endl;
cout<<"Synonym & Antonym"<<endl;
cout<<"INSRUCTION"<<endl;
cout<<"*********************************************
**********"<<endl;
cout<<"* Choose one of the possible out of four. *"<<endl;
cout<<"* You have to get at least 70 or above *"<<endl;
cout<<"* to pass the quiz. *"<<endl;
cout<<"*********************************************
**********"<<endl;
cout<<"Press ENTER to start the quiz"<<endl;
// Wait until user press enter
cin.get();
string Name;
cout<<"What is your name?"<<endl;
cin>> Name;
string Respond;
cout<<"Are you ready to take the quiz, "<<Name<<"?
Yes/No?"<<endl;
cin>>Respond;
//If the user enters "yes" the if block will execute.If enters
"no" else block will execute.
if (Respond == "yes")
{
cout<<endl;
cout<<"Good Luck!"<<endl;
cout<<endl;
}
else if (Respond == "no")
{
cout<<"Goodbye!"<<endl;
return 0;
}
//Creating an instance to Question class.
Question q1;
Question q2;
Question q3;
Question q4;
Question q5;
Question q6;
Question q7;
Question q8;
Question q9;
Question q10;
//Calling the function of Question class by using the instance of
Question.
//Calling the Function by passing the parameters.
q1.setValues("what is the synonym of stupid?",
"dumb",
"smart",
"clever",
"genious",
1,
10);
//Calling the function of Question class by using the instance of
Question.
//Calling the Function by passing the parameters.
q2.setValues("what is the synonym of beautiful? ",
"helpful",
"happy",
"ugly",
"pretty",
4,
10);
//Calling the function of Question class by using the instance of
Question.
//Calling the Function by passing the parameters.
q3.setValues("what is the synonym of stretch?",
"fetch",
"intense",
"expand",
"tease",
3,
10);
//Calling the function of Question class by using the instance of
Question.
//Calling the Function by passing the parameters.
q4.setValues("what is the synonym of happy?",
"negative",
"impossible",
"joyful",
"hateful",
3,
10);
//Calling the function of Question class by using the instance of
Question.
//Calling the Function by passing the parameters.
q5.setValues("what is the synonym of good?",
"dream",
"excellent",
"recycle",
"mean",
2,
10);
//Calling the function of Question class by using the instance of
Question.
//Calling the Function by passing the parameters.
q6.setValues("what is the antonym of dark?",
"bright",
"green",
"dim",
"cloudy",
1,
10);
//Calling the function of Question class by using the instance of
Question.
//Calling the Function by passing the parameters.
q7.setValues("what is the antonym of sucessful?",
"stright",
"pass",
"fullfil",
"fail",
4,
10);
//Calling the function of Question class by using the instance of
Question.
//Calling the Function by passing the parameters.
q8.setValues("what is the antonym of tight?",
"tiny",
"small",
"loose",
"stress",
3,
10);
//Calling the function of Question class by using the instance of
Question.
//Calling the Function by passing the parameters.
q9.setValues("what is the antonym of advantage? ",
"benefit",
"disadvantage",
"favor",
"improvement",
2,
10);
//Calling the function of Question class by using the instance of
Question.
//Calling the Function by passing the parameters.
q10.setValues("what is the antonym of strong?",
"hard",
"soft",
"weak",
"power",
3,
10);
//Calling the Function by using the class instance.
q1.askQuestion();
q2.askQuestion();
q3.askQuestion();
q4.askQuestion();
q5.askQuestion();
q6.askQuestion();
q7.askQuestion();
q8.askQuestion();
q9.askQuestion();
q10.askQuestion();
//Displaying the score.
cout<<"Your total score is"<<Total<<"out of 100"<<endl;
cout<<endl;
//If the total score is greater than 70 the if block is executed.If
not else block is executed which displays Messages to the user.
if(Total >= 70)
{
cout<<"Great, you passed the quiz!"<<endl;
cout<<endl;
cout<<"Congratulation"<<endl;}
else
{
cout<<"Sorry, you failed the quiz"<<endl;
cout<<"Better luck next time!"<<endl;
}
return 0;
}
//Function Implementation Which will set the values to the
varibles declared in the class.
void Question::setValues(string q, string a1, string a2, string
a3, string a4, int ca, int qs)
{
Question_Text = q;
Answer_1 = a1;
Answer_2 = a2;
Answer_3 = a3;
Answer_4 = a4;
Correct_Answer = ca;
Question_Score = qs;
}
//Function implementation which displays Each Question And
wait for the user to Answer each question.
void Question:: askQuestion()
{
cout<<endl;
cout<< Question_Text <<endl;
cout<<"1."<<Answer_1<<endl;
cout<<"2."<<Answer_2<<endl;
cout<<"3."<<Answer_3<<endl;
cout<<"4."<<Answer_4<<endl;
cout<<endl;
cout<<"what is your answer?"<<endl;
cin>>Guess;
//If the user enters correct answer add 10(Question_score) to
total.
// This will repeat till user answered all questions.
//If the user enters wrong answer the else block will get
executed which displays the correct answer.
if (Guess == Correct_Answer)
{
cout<<endl;
cout<<"Correct!"<<endl;
Total = Total + Question_Score;
}
else
{
cout<<endl;
cout<<"Incorect!"<<endl;
cout<<"The correct answer is "<<
Correct_Answer<<"."<<endl;
}
}
_____________________________________________________
______________________________

Contenu connexe

Similaire à C++ Quiz Program

Assessments
AssessmentsAssessments
Assessmentshccit
 
Below is my code for C++- I keep getting an error 43 5 C--Progr.pdf
Below is my code for C++- I keep getting an error  43    5    C--Progr.pdfBelow is my code for C++- I keep getting an error  43    5    C--Progr.pdf
Below is my code for C++- I keep getting an error 43 5 C--Progr.pdfanilbhagat17
 
java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docxjava compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docxpriestmanmable
 
How to write clean tests
How to write clean testsHow to write clean tests
How to write clean testsDanylenko Max
 
GeeCON 2012 Bad Tests, Good Tests
GeeCON 2012 Bad Tests, Good TestsGeeCON 2012 Bad Tests, Good Tests
GeeCON 2012 Bad Tests, Good TestsTomek Kaczanowski
 
Integration Project Inspection 3
Integration Project Inspection 3Integration Project Inspection 3
Integration Project Inspection 3Dillon Lee
 
We Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End DevelopmentWe Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End DevelopmentAll Things Open
 
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docxPROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docxamrit47
 
----------Evaluator-java---------------- package evaluator- import j.docx
----------Evaluator-java---------------- package evaluator-   import j.docx----------Evaluator-java---------------- package evaluator-   import j.docx
----------Evaluator-java---------------- package evaluator- import j.docxAdamq0DJonese
 
Program.cs class Program { static void Main(string[] args).pdf
Program.cs class Program { static void Main(string[] args).pdfProgram.cs class Program { static void Main(string[] args).pdf
Program.cs class Program { static void Main(string[] args).pdfanandshingavi23
 
Confitura 2012 Bad Tests, Good Tests
Confitura 2012 Bad Tests, Good TestsConfitura 2012 Bad Tests, Good Tests
Confitura 2012 Bad Tests, Good TestsTomek Kaczanowski
 
OverviewWe will be adding some validation to our Contact classes t.pdf
OverviewWe will be adding some validation to our Contact classes t.pdfOverviewWe will be adding some validation to our Contact classes t.pdf
OverviewWe will be adding some validation to our Contact classes t.pdffathimaoptical
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good TestsTomek Kaczanowski
 
DeVry GSP 115 Week 3 Assignment latest
DeVry GSP 115 Week 3 Assignment latestDeVry GSP 115 Week 3 Assignment latest
DeVry GSP 115 Week 3 Assignment latestAtifkhilji
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to javaciklum_ods
 
Programming with Java: the Basics
Programming with Java: the BasicsProgramming with Java: the Basics
Programming with Java: the BasicsJussi Pohjolainen
 
Esoft Metro Campus - Certificate in java basics
Esoft Metro Campus - Certificate in java basicsEsoft Metro Campus - Certificate in java basics
Esoft Metro Campus - Certificate in java basicsRasan Samarasinghe
 

Similaire à C++ Quiz Program (20)

Assessments
AssessmentsAssessments
Assessments
 
JAVA LOOP.pptx
JAVA LOOP.pptxJAVA LOOP.pptx
JAVA LOOP.pptx
 
Below is my code for C++- I keep getting an error 43 5 C--Progr.pdf
Below is my code for C++- I keep getting an error  43    5    C--Progr.pdfBelow is my code for C++- I keep getting an error  43    5    C--Progr.pdf
Below is my code for C++- I keep getting an error 43 5 C--Progr.pdf
 
java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docxjava compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
 
Kpi driven-java-development-fn conf
Kpi driven-java-development-fn confKpi driven-java-development-fn conf
Kpi driven-java-development-fn conf
 
How to write clean tests
How to write clean testsHow to write clean tests
How to write clean tests
 
GeeCON 2012 Bad Tests, Good Tests
GeeCON 2012 Bad Tests, Good TestsGeeCON 2012 Bad Tests, Good Tests
GeeCON 2012 Bad Tests, Good Tests
 
Integration Project Inspection 3
Integration Project Inspection 3Integration Project Inspection 3
Integration Project Inspection 3
 
We Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End DevelopmentWe Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End Development
 
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docxPROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
 
----------Evaluator-java---------------- package evaluator- import j.docx
----------Evaluator-java---------------- package evaluator-   import j.docx----------Evaluator-java---------------- package evaluator-   import j.docx
----------Evaluator-java---------------- package evaluator- import j.docx
 
Program.cs class Program { static void Main(string[] args).pdf
Program.cs class Program { static void Main(string[] args).pdfProgram.cs class Program { static void Main(string[] args).pdf
Program.cs class Program { static void Main(string[] args).pdf
 
Confitura 2012 Bad Tests, Good Tests
Confitura 2012 Bad Tests, Good TestsConfitura 2012 Bad Tests, Good Tests
Confitura 2012 Bad Tests, Good Tests
 
OverviewWe will be adding some validation to our Contact classes t.pdf
OverviewWe will be adding some validation to our Contact classes t.pdfOverviewWe will be adding some validation to our Contact classes t.pdf
OverviewWe will be adding some validation to our Contact classes t.pdf
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests
 
DeVry GSP 115 Week 3 Assignment latest
DeVry GSP 115 Week 3 Assignment latestDeVry GSP 115 Week 3 Assignment latest
DeVry GSP 115 Week 3 Assignment latest
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
 
Programming with Java: the Basics
Programming with Java: the BasicsProgramming with Java: the Basics
Programming with Java: the Basics
 
Esoft Metro Campus - Certificate in java basics
Esoft Metro Campus - Certificate in java basicsEsoft Metro Campus - Certificate in java basics
Esoft Metro Campus - Certificate in java basics
 
J Unit
J UnitJ Unit
J Unit
 

Plus de ajoy21

Please complete the assignment listed below.Define and explain, us.docx
Please complete the assignment listed below.Define and explain, us.docxPlease complete the assignment listed below.Define and explain, us.docx
Please complete the assignment listed below.Define and explain, us.docxajoy21
 
Please cite sources for each question. Do not use the same sources f.docx
Please cite sources for each question. Do not use the same sources f.docxPlease cite sources for each question. Do not use the same sources f.docx
Please cite sources for each question. Do not use the same sources f.docxajoy21
 
Please choose one of the following questions to answer for this week.docx
Please choose one of the following questions to answer for this week.docxPlease choose one of the following questions to answer for this week.docx
Please choose one of the following questions to answer for this week.docxajoy21
 
Please check the attachment for my paper.Please add citations to a.docx
Please check the attachment for my paper.Please add citations to a.docxPlease check the attachment for my paper.Please add citations to a.docx
Please check the attachment for my paper.Please add citations to a.docxajoy21
 
Please answer to this discussion post. No less than 150 words. Refer.docx
Please answer to this discussion post. No less than 150 words. Refer.docxPlease answer to this discussion post. No less than 150 words. Refer.docx
Please answer to this discussion post. No less than 150 words. Refer.docxajoy21
 
Please attach Non-nursing theorist summaries.JigsawExecutive .docx
Please attach Non-nursing theorist summaries.JigsawExecutive .docxPlease attach Non-nursing theorist summaries.JigsawExecutive .docx
Please attach Non-nursing theorist summaries.JigsawExecutive .docxajoy21
 
Please answer the question .There is no work count. PLEASE NUMBER .docx
Please answer the question .There is no work count. PLEASE NUMBER .docxPlease answer the question .There is no work count. PLEASE NUMBER .docx
Please answer the question .There is no work count. PLEASE NUMBER .docxajoy21
 
Please answer the following questions. Please cite your references..docx
Please answer the following questions. Please cite your references..docxPlease answer the following questions. Please cite your references..docx
Please answer the following questions. Please cite your references..docxajoy21
 
Please answer the following questions.1.      1.  Are you or.docx
Please answer the following questions.1.      1.  Are you or.docxPlease answer the following questions.1.      1.  Are you or.docx
Please answer the following questions.1.      1.  Are you or.docxajoy21
 
Please answer the following question with 200-300 words.Q. Discu.docx
Please answer the following question with 200-300 words.Q. Discu.docxPlease answer the following question with 200-300 words.Q. Discu.docx
Please answer the following question with 200-300 words.Q. Discu.docxajoy21
 
Please answer the following question Why do you think the US ha.docx
Please answer the following question Why do you think the US ha.docxPlease answer the following question Why do you think the US ha.docx
Please answer the following question Why do you think the US ha.docxajoy21
 
Please answer the following questions. Define tunneling in the V.docx
Please answer the following questions. Define tunneling in the V.docxPlease answer the following questions. Define tunneling in the V.docx
Please answer the following questions. Define tunneling in the V.docxajoy21
 
Please answer the following questions1. How can you stimulate the.docx
Please answer the following questions1. How can you stimulate the.docxPlease answer the following questions1. How can you stimulate the.docx
Please answer the following questions1. How can you stimulate the.docxajoy21
 
Please answer the following questions very deeply and presicely .docx
Please answer the following questions very deeply and presicely .docxPlease answer the following questions very deeply and presicely .docx
Please answer the following questions very deeply and presicely .docxajoy21
 
Please answer the following questions in an informal 1 ½ - 2-page es.docx
Please answer the following questions in an informal 1 ½ - 2-page es.docxPlease answer the following questions in an informal 1 ½ - 2-page es.docx
Please answer the following questions in an informal 1 ½ - 2-page es.docxajoy21
 
Please answer the following questions in a response of 150 to 200 wo.docx
Please answer the following questions in a response of 150 to 200 wo.docxPlease answer the following questions in a response of 150 to 200 wo.docx
Please answer the following questions in a response of 150 to 200 wo.docxajoy21
 
Please answer these questions regarding the (TILA) Truth in Lending .docx
Please answer these questions regarding the (TILA) Truth in Lending .docxPlease answer these questions regarding the (TILA) Truth in Lending .docx
Please answer these questions regarding the (TILA) Truth in Lending .docxajoy21
 
Please answer the following question pertaining to psychology. Inc.docx
Please answer the following question pertaining to psychology. Inc.docxPlease answer the following question pertaining to psychology. Inc.docx
Please answer the following question pertaining to psychology. Inc.docxajoy21
 
Please answer the following questions in a response of 250 to 300 .docx
Please answer the following questions in a response of 250 to 300 .docxPlease answer the following questions in a response of 250 to 300 .docx
Please answer the following questions in a response of 250 to 300 .docxajoy21
 
Please answer the three questions completly. I have attached the que.docx
Please answer the three questions completly. I have attached the que.docxPlease answer the three questions completly. I have attached the que.docx
Please answer the three questions completly. I have attached the que.docxajoy21
 

Plus de ajoy21 (20)

Please complete the assignment listed below.Define and explain, us.docx
Please complete the assignment listed below.Define and explain, us.docxPlease complete the assignment listed below.Define and explain, us.docx
Please complete the assignment listed below.Define and explain, us.docx
 
Please cite sources for each question. Do not use the same sources f.docx
Please cite sources for each question. Do not use the same sources f.docxPlease cite sources for each question. Do not use the same sources f.docx
Please cite sources for each question. Do not use the same sources f.docx
 
Please choose one of the following questions to answer for this week.docx
Please choose one of the following questions to answer for this week.docxPlease choose one of the following questions to answer for this week.docx
Please choose one of the following questions to answer for this week.docx
 
Please check the attachment for my paper.Please add citations to a.docx
Please check the attachment for my paper.Please add citations to a.docxPlease check the attachment for my paper.Please add citations to a.docx
Please check the attachment for my paper.Please add citations to a.docx
 
Please answer to this discussion post. No less than 150 words. Refer.docx
Please answer to this discussion post. No less than 150 words. Refer.docxPlease answer to this discussion post. No less than 150 words. Refer.docx
Please answer to this discussion post. No less than 150 words. Refer.docx
 
Please attach Non-nursing theorist summaries.JigsawExecutive .docx
Please attach Non-nursing theorist summaries.JigsawExecutive .docxPlease attach Non-nursing theorist summaries.JigsawExecutive .docx
Please attach Non-nursing theorist summaries.JigsawExecutive .docx
 
Please answer the question .There is no work count. PLEASE NUMBER .docx
Please answer the question .There is no work count. PLEASE NUMBER .docxPlease answer the question .There is no work count. PLEASE NUMBER .docx
Please answer the question .There is no work count. PLEASE NUMBER .docx
 
Please answer the following questions. Please cite your references..docx
Please answer the following questions. Please cite your references..docxPlease answer the following questions. Please cite your references..docx
Please answer the following questions. Please cite your references..docx
 
Please answer the following questions.1.      1.  Are you or.docx
Please answer the following questions.1.      1.  Are you or.docxPlease answer the following questions.1.      1.  Are you or.docx
Please answer the following questions.1.      1.  Are you or.docx
 
Please answer the following question with 200-300 words.Q. Discu.docx
Please answer the following question with 200-300 words.Q. Discu.docxPlease answer the following question with 200-300 words.Q. Discu.docx
Please answer the following question with 200-300 words.Q. Discu.docx
 
Please answer the following question Why do you think the US ha.docx
Please answer the following question Why do you think the US ha.docxPlease answer the following question Why do you think the US ha.docx
Please answer the following question Why do you think the US ha.docx
 
Please answer the following questions. Define tunneling in the V.docx
Please answer the following questions. Define tunneling in the V.docxPlease answer the following questions. Define tunneling in the V.docx
Please answer the following questions. Define tunneling in the V.docx
 
Please answer the following questions1. How can you stimulate the.docx
Please answer the following questions1. How can you stimulate the.docxPlease answer the following questions1. How can you stimulate the.docx
Please answer the following questions1. How can you stimulate the.docx
 
Please answer the following questions very deeply and presicely .docx
Please answer the following questions very deeply and presicely .docxPlease answer the following questions very deeply and presicely .docx
Please answer the following questions very deeply and presicely .docx
 
Please answer the following questions in an informal 1 ½ - 2-page es.docx
Please answer the following questions in an informal 1 ½ - 2-page es.docxPlease answer the following questions in an informal 1 ½ - 2-page es.docx
Please answer the following questions in an informal 1 ½ - 2-page es.docx
 
Please answer the following questions in a response of 150 to 200 wo.docx
Please answer the following questions in a response of 150 to 200 wo.docxPlease answer the following questions in a response of 150 to 200 wo.docx
Please answer the following questions in a response of 150 to 200 wo.docx
 
Please answer these questions regarding the (TILA) Truth in Lending .docx
Please answer these questions regarding the (TILA) Truth in Lending .docxPlease answer these questions regarding the (TILA) Truth in Lending .docx
Please answer these questions regarding the (TILA) Truth in Lending .docx
 
Please answer the following question pertaining to psychology. Inc.docx
Please answer the following question pertaining to psychology. Inc.docxPlease answer the following question pertaining to psychology. Inc.docx
Please answer the following question pertaining to psychology. Inc.docx
 
Please answer the following questions in a response of 250 to 300 .docx
Please answer the following questions in a response of 250 to 300 .docxPlease answer the following questions in a response of 250 to 300 .docx
Please answer the following questions in a response of 250 to 300 .docx
 
Please answer the three questions completly. I have attached the que.docx
Please answer the three questions completly. I have attached the que.docxPlease answer the three questions completly. I have attached the que.docx
Please answer the three questions completly. I have attached the que.docx
 

Dernier

Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxnelietumpap1
 

Dernier (20)

Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptx
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 

C++ Quiz Program

  • 1. #include <iostream> #include <string> using namespace std; int Guess; int Total; class Question { private: string Question_Text; string Answer_1; string Answer_2; string Answer_3; string Answer_4; int Correct_Answer; int Question_Score; public: void setValues (string,string,string,string,string, int, int); void askQuestion(); }; int main() { cout<<"Welcome to the Quiz Master"<<endl; cout<<"Synonym & Antonym"<<endl; cout<<"INSRUCTION"<<endl; cout<<"********************************************* **********"<<endl; cout<<"* Choose one of the possible out of four. *"<<endl; cout<<"* You have to get at least 70 or above *"<<endl; cout<<"* to pass the quiz. *"<<endl;
  • 2. cout<<"********************************************* **********"<<endl; cout<<"Press ENTER to start the quiz"<<endl; cin.get(); string Name; cout<<"What is your name?"<<endl; cin>> Name; string Respond; cout<<"Are you ready to take the quiz, "<<Name<<"? Yes/No?"<<endl; cin>>Respond; if (Respond == "yes") { cout<<endl; cout<<"Good Luck!"<<endl; cout<<endl; } else if (Respond == "no") { cout<<"Goodbye!"<<endl; return 0; } Question q1; Question q2; Question q3; Question q4; Question q5; Question q6; Question q7; Question q8; Question q9; Question q10; q1.setValues("what is the synonym of stupid?", "dumb", "smart",
  • 3. "clever", "genious", 1, 10); q2.setValues("what is the synonym of beautiful? ", "helpful", "happy", "ugly", "pretty", 4, 10); q3.setValues("what is the synonym of stretch?", "fetch", "intense", "expand", "tease", 3, 10); q4.setValues("what is the synonym of happy?", "negative", "impossible", "joyful", "hateful", 3, 10); q5.setValues("what is the synonym of good?", "dream", "excellent", "recycle", "mean", 2, 10); q6.setValues("what is the antonym of dark?", "bright", "green", "dim",
  • 4. "cloudy", 1, 10); q7.setValues("what is the antonym of sucessful? ", "stright", "pass", "fullfil", "fail", 4, 10); q8.setValues("what is the antonym of tight?", "tiny", "small", "loose", "stress", 3, 10); q9.setValues("what is the antonym of advantage? ", "benefit", "disadvantage", "favor", "improvement", 2, 10); q10.setValues("what is the antonym of strong?", "hard", "soft", "weak", "power", 3, 10); q1.askQuestion(); q2.askQuestion(); q3.askQuestion(); q4.askQuestion();
  • 5. q5.askQuestion(); q6.askQuestion(); q7.askQuestion(); q8.askQuestion(); q9.askQuestion(); q10.askQuestion(); cout<<"Your total score is"<<Total<<"out of 100"<<endl; cout<<endl; if(Total >= 70) { cout<<"Great, you passed the quiz!"<<endl; cout<<endl; cout<<"Congratulation"<<endl;} else { cout<<"Sorry, you failed the quiz"<<endl; cout<<"Better luck next time!"<<endl; } return 0; } void Question::setValues(string q, string a1, string a2, string a3, string a4, int ca, int qs) { Question_Text = q; Answer_1 = a1; Answer_2 = a2; Answer_3 = a3; Answer_4 = a4; Correct_Answer = ca; Question_Score = qs; }
  • 6. void Question:: askQuestion() { cout<<endl; cout<< Question_Text <<endl; cout<<"1."<<Answer_1<<endl; cout<<"2."<<Answer_2<<endl; cout<<"3."<<Answer_3<<endl; cout<<"4."<<Answer_4<<endl; cout<<endl; cout<<"what is your answer?"<<endl; cin>>Guess; if (Guess == Correct_Answer) { cout<<endl; cout<<"Correct!"<<endl; Total = Total + Question_Score; } else { cout<<endl; cout<<"Incorect!"<<endl; cout<<"The correct answer is "<< Correct_Answer<<"."<<endl; } } Please give me some comments as well as the clues of how this program works. Thank you
  • 7. Solution Program Execution starts from the main method.The program will wait till the user presses enter button.And asks for the name, and asks for whether he is ready to take the quiz.if the user enters “yes” It will start the quiz by wishing you good luck.If the user enters “no” the program will terminate by displaying a message good bye. If the user enters “yes” then the program will create multiple instances to the class “Question”. Question q1; Question q2; Question q3; Question q4; Question q5; Question q6; Question q7; Question q8; Question q9; Question q10; After that using the instances it will call the function of the class “Question” .
  • 8. It will call the function by passing the parameters which will set the values to the class variables. After that it will call another function which will displays the Questions And waiting for the user to enter the option. If the answer is correct it will calculate the score by adding the score to the total.If the user entered answer is wrong it displays the correct answer. Finally if the total score of the quiz is greater than or equal to 70.then it displays a message that the user passed the exam. If he got less score than 70 it displays the message that he failed in the exam. _____________________________________________________ ____________________________________ Quiz.cpp #include <iostream> #include <string> using namespace std; //Declaring Global Variables which we can use any where in the program. int Guess; int Total; // Creating the class class Question {
  • 9. private: //declaring variables. string Question_Text; string Answer_1; string Answer_2; string Answer_3; string Answer_4; int Correct_Answer; int Question_Score; public: //Functions. void setValues (string,string,string,string,string, int, int); void askQuestion(); }; int main() { //Displaying messages. cout<<"Welcome to the Quiz Master"<<endl; cout<<"Synonym & Antonym"<<endl; cout<<"INSRUCTION"<<endl; cout<<"********************************************* **********"<<endl;
  • 10. cout<<"* Choose one of the possible out of four. *"<<endl; cout<<"* You have to get at least 70 or above *"<<endl; cout<<"* to pass the quiz. *"<<endl; cout<<"********************************************* **********"<<endl; cout<<"Press ENTER to start the quiz"<<endl; // Wait until user press enter cin.get(); string Name; cout<<"What is your name?"<<endl; cin>> Name; string Respond; cout<<"Are you ready to take the quiz, "<<Name<<"? Yes/No?"<<endl; cin>>Respond; //If the user enters "yes" the if block will execute.If enters "no" else block will execute. if (Respond == "yes") { cout<<endl; cout<<"Good Luck!"<<endl; cout<<endl; } else if (Respond == "no")
  • 11. { cout<<"Goodbye!"<<endl; return 0; } //Creating an instance to Question class. Question q1; Question q2; Question q3; Question q4; Question q5; Question q6; Question q7; Question q8; Question q9; Question q10; //Calling the function of Question class by using the instance of Question. //Calling the Function by passing the parameters. q1.setValues("what is the synonym of stupid?", "dumb", "smart", "clever", "genious", 1, 10);
  • 12. //Calling the function of Question class by using the instance of Question. //Calling the Function by passing the parameters. q2.setValues("what is the synonym of beautiful? ", "helpful", "happy", "ugly", "pretty", 4, 10); //Calling the function of Question class by using the instance of Question. //Calling the Function by passing the parameters. q3.setValues("what is the synonym of stretch?", "fetch", "intense", "expand", "tease", 3, 10); //Calling the function of Question class by using the instance of Question. //Calling the Function by passing the parameters. q4.setValues("what is the synonym of happy?", "negative",
  • 13. "impossible", "joyful", "hateful", 3, 10); //Calling the function of Question class by using the instance of Question. //Calling the Function by passing the parameters. q5.setValues("what is the synonym of good?", "dream", "excellent", "recycle", "mean", 2, 10); //Calling the function of Question class by using the instance of Question. //Calling the Function by passing the parameters. q6.setValues("what is the antonym of dark?", "bright", "green", "dim", "cloudy", 1, 10);
  • 14. //Calling the function of Question class by using the instance of Question. //Calling the Function by passing the parameters. q7.setValues("what is the antonym of sucessful?", "stright", "pass", "fullfil", "fail", 4, 10); //Calling the function of Question class by using the instance of Question. //Calling the Function by passing the parameters. q8.setValues("what is the antonym of tight?", "tiny", "small", "loose", "stress", 3, 10); //Calling the function of Question class by using the instance of Question. //Calling the Function by passing the parameters. q9.setValues("what is the antonym of advantage? ", "benefit",
  • 15. "disadvantage", "favor", "improvement", 2, 10); //Calling the function of Question class by using the instance of Question. //Calling the Function by passing the parameters. q10.setValues("what is the antonym of strong?", "hard", "soft", "weak", "power", 3, 10); //Calling the Function by using the class instance. q1.askQuestion(); q2.askQuestion(); q3.askQuestion(); q4.askQuestion(); q5.askQuestion(); q6.askQuestion(); q7.askQuestion(); q8.askQuestion(); q9.askQuestion();
  • 16. q10.askQuestion(); //Displaying the score. cout<<"Your total score is"<<Total<<"out of 100"<<endl; cout<<endl; //If the total score is greater than 70 the if block is executed.If not else block is executed which displays Messages to the user. if(Total >= 70) { cout<<"Great, you passed the quiz!"<<endl; cout<<endl; cout<<"Congratulation"<<endl;} else { cout<<"Sorry, you failed the quiz"<<endl; cout<<"Better luck next time!"<<endl; } return 0; } //Function Implementation Which will set the values to the varibles declared in the class. void Question::setValues(string q, string a1, string a2, string a3, string a4, int ca, int qs)
  • 17. { Question_Text = q; Answer_1 = a1; Answer_2 = a2; Answer_3 = a3; Answer_4 = a4; Correct_Answer = ca; Question_Score = qs; } //Function implementation which displays Each Question And wait for the user to Answer each question. void Question:: askQuestion() { cout<<endl; cout<< Question_Text <<endl; cout<<"1."<<Answer_1<<endl; cout<<"2."<<Answer_2<<endl; cout<<"3."<<Answer_3<<endl; cout<<"4."<<Answer_4<<endl; cout<<endl;
  • 18. cout<<"what is your answer?"<<endl; cin>>Guess; //If the user enters correct answer add 10(Question_score) to total. // This will repeat till user answered all questions. //If the user enters wrong answer the else block will get executed which displays the correct answer. if (Guess == Correct_Answer) { cout<<endl; cout<<"Correct!"<<endl; Total = Total + Question_Score; } else { cout<<endl; cout<<"Incorect!"<<endl; cout<<"The correct answer is "<< Correct_Answer<<"."<<endl;