#include <iostream>
# include <string>
# include <fstream>
bool validQuestion(char Question1);
using namespace std;
{
char response; //Get response from players
char Question1, Question2, Question3, Question4, Question5;
bool valid = false;
int score1 = 0;
int score2 = 0;
string name1; //name of player1
string name2; // name of player2
cout << "Enter Y/y to play the game, then press the enter key";
cin >> response;
cout << endl;
if (response == 'Y' || response == 'y')
Questions();
while (response == 'Y' || response == 'y')
{
do
{
cout << name1 << "please enter your answers for each question.\n"
<< "Your answers can be entered in uppercase or lowercase letters.\n"
<< "Press the enter key after selecting your choice\n";
cin >> Question1;
cout << endl;
valid = validQuestion(Question1);
}
while (valid != true);
do
{
cout << name2 << "please enter your answers for each question.\n"
<< "Your answers can be entered in uppercase or lowercase letters.\n"
<< "Press the enter key after selecting your choice\n";
cin >> Question1;
cout << endl;
valid = validQuestion(Question1);
}
while (valid != true);
cout << "Here is where we find out who the \"Smartest\" and \"Dumbest\" is.\n"
<< "If " << name1 << " is the \"Smartest\" then we know that " << name2
<< "is the \"Dumbest\" and if " << name2 << " is the \"Smartest\" then\n"
<< "we know that " << name1 << " is the \"Dumbest.\"" << endl;
cout << endl;
}
cin.get();
return 0;
}
bool validQuestion(char Question1) //function call to validQuestions
{
bool verify;
switch (Question1)
{
case 'A':
cout << "Wrong Answer" << endl;
break;
case 'a':
cout << "Wrong Answer" << endl;
break;
case 'B':
cout << "Wrong Answer" << endl;
break;
case 'b':
cout << "Wrong Answer" << endl;
break;
case 'C':
cout << "This is the correct answer" << endl;
break;
case 'c':
cout << "This is the correct answer" << endl;
break;
case 'D':
cout << "Wrong Answer" << endl;
break;
case 'd':
cout << "Wrong Answer" << endl;
break;
verify = true;
return verify;
default:
cout << "You entered a invalid selection - please try again" << endl;
verify = false;
return verify;
}
}
// I have more code in this program of course and have thus far got to this point. My problem is is that I want to go to question 2, 3, 4, and 5 still and do not know if I need a switch structure for each question. Each case in the switch structure is for multiple choice answers for a, b, c, and d. All five questions in this trivia game are multiple choice questions. After all the questions are answered by each player I have to show who got the highest score out of five questions.
To all computer master wizards I beg for knowledge for a soluition as after all,
"I am the knightRider and kit is in the shop for vechile repairs.
#include <iostream>
# include <string>
# include <fstream>
bool validQuestion(char Question1);
using namespace std;
{
char response; //Get response from players
char Question1, Question2, Question3, Question4, Question5;
bool valid = false;
int score1 = 0;
int score2 = 0;
string name1; //name of player1
string name2; // name of player2
cout << "Enter Y/y to play the game, then press the enter key";
cin >> response;
cout << endl;
if (response == 'Y' || response == 'y')
Questions();
while (response == 'Y' || response == 'y')
{
do
{
cout << name1 << "please enter your answers for each question.\n"
<< "Your answers can be entered in uppercase or lowercase letters.\n"
<< "Press the enter key after selecting your choice\n";
cin >> Question1;
cout << endl;
valid = validQuestion(Question1);
}
while (valid != true);
do
{
cout << name2 << "please enter your answers for each question.\n"
<< "Your answers can be entered in uppercase or lowercase letters.\n"
<< "Press the enter key after selecting your choice\n";
cin >> Question1;
cout << endl;
valid = validQuestion(Question1);
}
while (valid != true);
cout << "Here is where we find out who the \"Smartest\" and \"Dumbest\" is.\n"
<< "If " << name1 << " is the \"Smartest\" then we know that " << name2
<< "is the \"Dumbest\" and if " << name2 << " is the \"Smartest\" then\n"
<< "we know that " << name1 << " is the \"Dumbest.\"" << endl;
cout << endl;
}
cin.get();
return 0;
}
bool validQuestion(char Question1) //function call to validQuestions
{
bool verify;
switch (Question1)
{
case 'A':
cout << "Wrong Answer" << endl;
break;
case 'a':
cout << "Wrong Answer" << endl;
break;
case 'B':
cout << "Wrong Answer" << endl;
break;
case 'b':
cout << "Wrong Answer" << endl;
break;
case 'C':
cout << "This is the correct answer" << endl;
break;
case 'c':
cout << "This is the correct answer" << endl;
break;
case 'D':
cout << "Wrong Answer" << endl;
break;
case 'd':
cout << "Wrong Answer" << endl;
break;
verify = true;
return verify;
default:
cout << "You entered a invalid selection - please try again" << endl;
verify = false;
return verify;
}
}
// I have more code in this program of course and have thus far got to this point. My problem is is that I want to go to question 2, 3, 4, and 5 still and do not know if I need a switch structure for each question. Each case in the switch structure is for multiple choice answers for a, b, c, and d. All five questions in this trivia game are multiple choice questions. After all the questions are answered by each player I have to show who got the highest score out of five questions.
To all computer master wizards I beg for knowledge for a soluition as after all,
"I am the knightRider and kit is in the shop for vechile repairs.