#include <iostream>
using namespace std;
char* test(char* option);
int main(int argc, char* argv[])
{
char menu[4] = "Yes";
while ( strcmp (menu, "No") != 0)
{
char option[5];
cout << "Trivia Game!\n";
cin.get();
cout << "Please choose an option: ";
cout << "\nPlay\nQuit";
cout << "\nYour choice: ";
cin.getline (option, 5, '\n' );
while ( strcmp (test(option), "QUIT") != 0)
{
cout << "Hit ENTER to play!";
cin.get();
// ============================== START FIRST QUESTION ==============================
char questionone[50] = "\nWhat country is Tsing Tao beer brewed in?";
char answerone[20];
cout << " " << questionone << " ";
cout << "\nYour answer: ";
cin.getline (answerone, 20, '\n');
// ================================ START ANSWERS ===================================
if ( strcmp (test(answerone), "CHINA") == 0 )
{
cout << "Correct!";
cin.get();
}
else
{
cout << "Wrong! It was China!";
cin.get();
}
// ================================= END ANSWERS, FIRST QUESTION =====================
cout << "\nContinue to Play or Quit?";
cout << "\nYour choice: ";
cin >> option;
if (strcmp (test(option), "QUIT") == 0)
{
return 0;
}
else
{
}
// ================================== START SECOND QUESTION ===========================
char questiontwo[100] = "\nWhat color belt does an improving judo practitioner trade in for brown?";
char answertwo[20];
cout << " " << questiontwo << " ";
cout << "\nYour answer: ";
cin >> answertwo;
cout << "";
// ================================== START ANSWERS ====================================
if (strcmp (test(answertwo), "BLUE") == 0)
{
cout << "Correct!\n";
cin.get();
}
else
{
cout << "Wrong! It was blue!";
cin.get();
}
// =================================== END ANSWERS, SECOND QUESTION =====================
cin.get();
cout << "Continue to Play or Quit?";
cout << "\nYour choice: ";
cin >> option;
if (strcmp (test(option), "QUIT") == 0)
{
return 0;
}
else
{
}
// =================================== START THIRD QUESTION =============================
char questionthree[100] = "\nWhat Asian island country boasts the most followers of Mohammed?";
char answerthree[20];
cout << " " << questionthree << " ";
cout << "\nYour answer: ";
cin >> answerthree;
cout << "";
// ================================== START ANSWERS ====================================
if (strcmp (test(answerthree), "INDONESIA") == 0)
{
cout << "Correct!\n";
cin.get();
}
else
{
cout << "Wrong! It was Indonesia!";
cout << "";
cin.get();
}
// =================================== END ANSWERS, THIRD QUESTION =====================
cin.get();
cout << "\nContinue to Play or Quit?";
cout << "\nYour choice: ";
cin >> option;
if (strcmp (test(option), "QUIT") == 0)
{
return 0;
}
else
{
}
// =================================== START FOURTH QUESTION =============================
char questionfour[100] = "\nWhat does 'secco' mean on a bottle of Italian wine?";
char answerfour[20];
cout << " " << questionfour << " ";
cout << "\nYour answer: ";
cin >> answerfour;
cout << "";
// ================================== START ANSWERS ====================================
if (strcmp (test(answerfour), "DRY") == 0)
{
cout << "Correct!\n";
cin.get();
}
else
{
cout << "Wrong! It means 'Dry'!";
cin.get();
}
// =================================== END ANSWERS, FOURTH QUESTION =====================
cin.get();
cout << "Continue to Play or Quit?";
cout << "\nYour choice: ";
cin >> option;
if (strcmp (test(option), "QUIT") == 0)
{
return 0;
}
else
{
}
// =================================== START FIFTH QUESTION =============================
char questionfive[100] = "\nWhat European country, apart from Vatican City, flies a square flag?";
char answerfive[20];
cout << " " << questionfive << " ";
cout << "\nYour answer: ";
cin >> answerfive;
cout << "";
// ================================== START ANSWERS ====================================
if (strcmp (test(answerfive), "SWITZERLAND") == 0)
{
cout << "Correct!\n";
cin.get();
}
else
{
cout << "Wrong! It was Switzerland!";
cin.get();
}
// =================================== END ANSWERS, FIFTH QUESTION =====================
cin.get();
cout << "Continue to Play or Quit?";
cout << "\nYour choice: ";
cin >> option;
if (strcmp (test(option), "QUIT") == 0)
{
return 0;
}
else
{
}
// =================================== START SIXTH QUESTION =============================
char questionsix[100] = "\nHow many South American countries have the letter 'Z' in their names?";
char answersix[20];
cout << " " << questionsix << " ";
cout << "\nYour answer: ";
cin >> answersix;
cout << "";
// ================================== START ANSWERS ====================================
if (strcmp (test(answersix), "TWO") == 0)
{
cout << "Correct! Venezuela and Brazil!\n";
cin.get();
}
else
{
cout << "Wrong! They are Venezuela and Brazil!";
cin.get();
}
// =================================== END ANSWERS, SIXTH QUESTION =====================
cin.get();
cout << "Continue to Play or Quit?";
cout << "\nYour choice: ";
cin >> option;
if (strcmp (test(option), "QUIT") == 0)
{
return 0;
}
else
{
}
// =================================== START SEVENTH QUESTION =============================
char questionseven[100] = "\nWhich is older - chess or checkers?";
char answerseven[20];
cout << " " << questionseven << " ";
cout << "\nYour answer: ";
cin >> answerseven;
cout << "";
// ================================== START ANSWERS ====================================
if (strcmp (test(answerseven), "CHECKERS") == 0)
{
cout << "Correct!\n";
cin.get();
}
else
{
cout << "Wrong! It was Checkers!";
cin.get();
}
// =================================== END ANSWERS, SEVENTH QUESTION =====================
cin.get();
cout << "Continue to Play or Quit?";
cout << "\nYour choice: ";
cin >> option;
if (strcmp (test(option), "QUIT") == 0)
{
return 0;
}
else
{
}
// =================================== START EIGHTH QUESTION =============================
char questioneight[100] = "\nWhat European city are you heading for if your baggage tags read AMS?";
char answereight[20];
cout << " " << questioneight << " ";
cout << "\nYour answer: ";
cin >> answereight;
cout << "";
// ================================== START ANSWERS ====================================
if (strcmp (test(answereight), "AMSTERDAM") == 0)
{
cout << "Correct!\n";
cin.get();
}
else
{
cout << "Wrong! It was Amsterdam!";
cin.get();
}
// =================================== END ANSWERS, EIGHTH QUESTION =====================
cin.get();
cout << "Continue to Play or Quit?";
cout << "\nYour choice: ";
cin >> option;
if (strcmp (test(option), "QUIT") == 0)
{
return 0;
}
else
{
}
// =================================== START NINETH QUESTION =============================
char questionnine[100] = "\nWhat color appears on the flags of all Islamic countries?";
char answernine[20];
cout << " " << questionnine << " ";
cout << "\nYour answer: ";
cin >> answernine;
cout << "";
// ================================== START ANSWERS ====================================
if (strcmp (test(answernine), "GREEN") == 0)
{
cout << "Correct!\n";
cin.get();
}
else
{
cout << "Wrong! It was Green!";
cin.get();
}
// =================================== END ANSWERS, NINETH QUESTION =====================
cin.get();
cout << "Continue to Play or Quit?";
cout << "\nYour choice: ";
cin >> option;
if (strcmp (test(option), "QUIT") == 0)
{
return 0;
}
else
{
}
// =================================== START TENTH QUESTION =============================
char questionten[100] = "\nWhat travel in gaggles?";
char answerten[20];
cout << " " << questionten << " ";
cout << "\nYour answer: ";
cin >> answerten;
cout << "";
// ================================== START ANSWERS ====================================
if (strcmp (test(answerten), "GEESE") == 0)
{
cout << "Correct!\n";
cin.get();
}
else
{
cout << "Wrong! It was Geese!";
cin.get();
}
// =================================== END ANSWERS, TENTH QUESTION =====================
cin.get();
cout << "Continue to Play or Quit?";
cout << "\nYour choice: ";
cin >> option;
if (strcmp (test(option), "QUIT") == 0)
{
return 0;
}
else
{
}
cin.get();
cout << "\nThank you for playing. I hope you enjoyed it.";
cin.get();
return 0;
}
while ( strcmp (test(option), "QUIT") == 0)
{
return 0;
}
}
}
char* test(char* option)
{
// Set up the temporary variables
int i, length;
length = strlen(option);
// Loop through the word, making each letter uppercase
for (i=0; i<length; i++)
{
option[i] = toupper(option[i]);
}
// Return the string
return option;
}