What it does is when you answer the first question it gives you your reward and then goes to the next question. The problem with that is when it goes to the next question it doesn't change the question, just the answers. I have tried to add a second question with the right words for the question at the "void Question:askQuestion()" section. Sorry if this doesn't make very much sense.
/*
The Great Quiz Show Game
by
Seth A----
*/
#include <iostream>
#include <string>
using namespace std;
int Guess;
int Winnings;
//Define question class
class Question
{
private:
string Question_Text;
string Answer_1;
string Answer_2;
string Answer_3;
string Answer_4;
int Correct_Answer;
int Prize_Ammount;
public
:void setValues(string, string, string, string, string, int, int);
void askQuestion();
};
int main()
{
//declare local variables
int High_Score[5];
string High_Score_Name[5];
//initialize local variable
High_Score[0] = 25000;
High_Score[1] = 12000;
High_Score[2] = 7500;
High_Score[3] = 4000;
High_Score[4] = 2000;
High_Score_Name[0] = "Gweneth";
High_Score_Name[1] = "Adam";
High_Score_Name[2] = "Nastasia";
High_Score_Name[3] = "Nicolas";
High_Score_Name[4] = "Dani";
cout << "***********************" << endl;
cout << "* *" << endl;
cout << "* The Great Quiz Show *" << endl;
cout << "* *" << endl;
cout << "* by *" << endl;
cout << "* *" << endl;
cout << "* Seth Alpha *" << endl;
cout << "* *" << endl;
cout << "***********************" << endl;
cout << endl;
//instances of questions
Question q1;
Question q2;
q1.setValues("What does cout do?",
"Eject a CD",
"Send text to the printer",
"Print text on the screen",
"Play a sound",
3,
2500);
q2.setValues("What are the two sections in a class?",
"Public and local",
"Global and local",
"Global and private",
"Public and private",
4,
5000);
//ask questions
q1.askQuestion();
q2.askQuestion();
//print HS list
cout << "High Score List" << endl;
cout << endl;
for (int i = 0; i < 5; i++)
{
cout << High_Score[i] << "" << High_Score_Name[i] << endl;
}
}
void Question::setValues(string q, string a1, string a2, string a3, string a4, int ca, int pa)
{
Question_Text = q;
Answer_1 = a1;
Answer_2 = a2;
Answer_3 = a3;
Answer_4 = a4;
Correct_Answer = ca;
Prize_Ammount = pa;
}
void Question::askQuestion()
{
cout << endl;
cout << "What does cout do?" << endl;
cout << "1." << Answer_1 << endl;
cout << "2." << Answer_2 << endl;
cout << "3." << Answer_3 << endl;
cout << "4." << Answer_4 << endl;
cout << endl;
//ask for guess
cout << "What is your answer?" << endl;
cin >> Guess;
//if correct add Prize_Ammount to Winnings
if (Guess == Correct_Answer)
{
cout << endl;
cout << "You are correct!" << endl;
Winnings = Winnings + Prize_Ammount
; cout << "You just won $" << Prize_Ammount << "!" << endl;
cout << "Total winnings: $" << Winnings << endl;
cout << endl;
}
else
{
cout << endl;
cout << "You are not correct" << endl;
cout << "Total winnings: $" << Winnings << endl;
cout << endl;
}
}