Write a C program that implements a simple TVmovie trivia ga

Write a C++ program that implements a simple TV/movie trivia game. The program begins by
welcoming the prospective player to the game, then asks the player if s/he is ready to play. If the player
responds “N” or “n” for “no,” the program displays an appropriate message and ends. If the player
responds “Y” or “y” for “yes,” the program displays a question and prompts the player to enter an
answer. If the player responds correctly, the program displays “You are correct!” (or something similar).
If the player responds incorrectly, the program responds “Nice try, but no.” (or something similar). The
program then asks the player if s/he wants to play again. If the player responds in the affirmative (“Y” or
“y”), the program displays another question; otherwise, it thanks the player for playing and ends. The
program must continue to loop until the player decides to quit playing. As usual, your program output
should resemble the sample runs at the end of this document.
Notes:
• Your program must employ a minimum of 10 question/answer pairs.
• Your program must store the questions in one array and the answers in a second array (i.e., employ
parallel arrays).
• Answers must be case-insensitive. For example, if the answer to a “Star Wars” question is “YODA,”
and the player answers “Yoda,” the player’s answer is considered correct. Please note that on page 3
I have provided two functions that you may use to convert the player’s answer to all uppercase or all
lowercase as appropriate.
• The trivia game questions must be selected randomly.



Please ASAP!!

Sample run #1 (Player decides to play and an wers several questions e1come to the Sci-Fi TV and Movie Trivia Game Ready to play CY/N)7 y In what U.S. state is warehouse 13 located? orth Dakota ice try, but no Play again CY/N)7 Y By what name did the eleventh Doctor refer to the TARDIS? SEXY You are correct! Play again CY/N)7 y ho is the next intended Caretaker of warehouse 137 Adele ice try, but no. Play again CY/N)? y Rogue one: A Star wars Story\" opens on what date in Decenber 2016? 16 You are correct! Play again CY/N)7 n Thanks for playing the sci-Fi TV and Movie Trivia Game! Come again soon! Sample run #2 (Player decides not to play.): elcome to the Sci-Fi TV and Movie Trivia Game Ready to play CY/N)7 n aybe another time Press any key to continue

Solution

Please edit the questions and answers. Not all of them are Sci-Fi.

Program code:

#include <iostream>
#include <cstring>
#include <string>


using namespace std;

//varaibles to hold the questions and answers

string questions[10];

string answers[10];

//This function will add the questions and answers intot he array

void setQuestionsAndAnswers()

{

questions[0] = \"In what U.S. state is warehouse 13 located? \";

answers[0] = \"south dakota\";

questions[1] = \"Who played the character Hermoine Granger in Harry Potter series?\";

answers[1] = \"emma watson\";

questions[2] = \"What is Orlando Bloom\'s character\'s name in Pirates of the Caribbean series?\";

answers[2] = \"william turner\";

questions[3] = \"In what movie did Julia Roberts play an unmarried woman who could not commit to one man ?\";

answers[3] = \"runaway bride\";

questions[4] = \"In \\\"Legends of the Fall\\\" which actor plays the elder brother?\";

answers[4] = \"aidan quinn\";

questions[5] = \"Who plays the main character in Hitch?\";

answers[5] = \"will smith\";

questions[6] = \"What is the name of Harry Potter\'s owl?\";

answers[6] = \"hedwig\";

questions[7] = \"Who stars alongside Jackie Chan in Rush Hour? \";

answers[7] = \"chris tucker\";

questions[8] = \"Which actor voiced Smaug, the Dragon in Hobbit series?\";

answers[8] = \"benedict cumberbatch\";

questions[9] = \"What is the name of Tony Stark\'s girl friend? \";

answers[9] = \"pepper pots\";

}

int main()

{

char isReady;

cout<<endl<<\"Welcome to the Sci-Fi Tv and Movie Trivia Game!\"<<endl<<endl<<\"Ready to play (Y/N)? \";

cin>>isReady;

cout<<endl<<\"--------------------------------------------------------------------------\"<<endl;

//checking if the user is ready

if(isReady == \'Y\' || isReady == \'y\')

{

//calling the function to add questions and answers into the array

setQuestionsAndAnswers();

int i=0;

char choice;

do

{

cin.ignore();

string answer = \"\";

cout<<endl<<questions[i]<<endl;

getline(cin,answer);

//converting all the characters of the user entered answer to lower case
          
char s[answer.size()];
strcpy(s,answer.c_str());
for(int j=0;s[j]!=\'\\0\';j++)
           {
               s[j]=tolower(s[j]);
           }
           answer = string(s);
//comparing the answer provided by the user with the answer in the array
      
if(answer.compare(answers[i]) == 0)

{

cout<<endl<<\"You are correct!\"<<endl<<endl<<\"Play again (Y/N)? \";

cin>>choice;

cout<<endl<<\"--------------------------------------------------------------------------\"<<endl;

i++;

}

else

{

cout<<endl<<\"Nice try but no\"<<endl<<endl<<\"Play again (Y/N)? \"<<endl;

cin>>choice;

cout<<endl<<\"--------------------------------------------------------------------------\"<<endl;

i++;

}

}while(choice ==\'y\' || choice ==\'Y\');

cout<<endl<<\"Thanks for playing the Sci-Fi Tv and Movie Trivia Game!\"<<endl;

cout<<\"Come again soon\"<<endl;

cout<<endl<<\"--------------------------------------------------------------------------\"<<endl;

}

else

{

cout<<endl<<\"May be another time...\"<<endl;

cout<<endl<<\"--------------------------------------------------------------------------\"<<endl;

cout<<endl<<\"Press any key to continue...\";

}

return 0;

}

OUTPUT:

Run #1

Welcome to the Sci-Fi Tv and Movie Trivia Game!

Ready to play (Y/N)? y

--------------------------------------------------------------------------

In what U.S. state is warehouse 13 located?

south dakota

You are correct!

Play again (Y/N)? y

--------------------------------------------------------------------------

Who played the character Hermoine Granger in Harry Potter series?

emma watson

You are correct!

Play again (Y/N)? n

--------------------------------------------------------------------------

Thanks for playing the Sci-Fi Tv and Movie Trivia Game!

Come again soon

--------------------------------------------------------------------------

Run #2

Welcome to the Sci-Fi Tv and Movie Trivia Game!

Ready to play (Y/N)? n

--------------------------------------------------------------------------

May be another time...

--------------------------------------------------------------------------

Press any key to continue...

Run #3

Welcome to the Sci-Fi Tv and Movie Trivia Game!

Ready to play (Y/N)? y

--------------------------------------------------------------------------

In what U.S. state is warehouse 13 located?

south dakota

You are correct!

Play again (Y/N)? n

--------------------------------------------------------------------------

Thanks for playing the Sci-Fi Tv and Movie Trivia Game!

Come again soon

--------------------------------------------------------------------------

Run #4

Welcome to the Sci-Fi Tv and Movie Trivia Game!

Ready to play (Y/N)? y

--------------------------------------------------------------------------

In what U.S. state is warehouse 13 located?

South Dakota

You are correct!

Play again (Y/N)? n

--------------------------------------------------------------------------

Thanks for playing the Sci-Fi Tv and Movie Trivia Game!

Come again soon

--------------------------------------------------------------------------

Alternative solution with algorithm header

Program Code:

/*
* MovieGame.cpp
*
* Created on: 09-Nov-2016
* Author: Kaju
*/
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

//varaibles to hold the questions and answers
string questions[10];
string answers[10];

//This function will add the questions and answers intot he array
void setQuestionsAndAnswers()
{
   questions[0] = \"In what U.S. state is warehouse 13 located? \";
   answers[0] = \"south dakota\";

   questions[1] = \"Who played the character Hermoine Granger in Harry Potter series?\";
   answers[1] = \"emma watson\";

   questions[2] = \"What is Orlando Bloom\'s character\'s name in Pirates of the Caribbean series?\";
   answers[2] = \"william turner\";

   questions[3] = \"In what movie did Julia Roberts play an unmarried woman who could not commit to one man ?\";
   answers[3] = \"runaway bride\";

   questions[4] = \"In \\\"Legends of the Fall\\\" which actor plays the elder brother?\";
   answers[4] = \"aidan quinn\";

   questions[5] = \"Who plays the main character in Hitch?\";
   answers[5] = \"will smith\";

   questions[6] = \"What is the name of Harry Potter\'s owl?\";
   answers[6] = \"hedwig\";

   questions[7] = \"Who stars alongside Jackie Chan in Rush Hour? \";
   answers[7] = \"chris tucker\";

   questions[8] = \"Which actor voiced Smaug, the Dragon in Hobbit series?\";
   answers[8] = \"benedict cumberbatch\";

   questions[9] = \"What is the name of Tony Stark\'s girl friend? \";
   answers[9] = \"pepper pots\";
}

int main()
{

   char isReady;
   cout<<endl<<\"Welcome to the Sci-Fi Tv and Movie Trivia Game!\"<<endl<<endl<<\"Ready to play (Y/N)? \";
   cin>>isReady;
   cout<<endl<<\"--------------------------------------------------------------------------\"<<endl;

   //checking if the user is ready
   if(isReady == \'Y\' || isReady == \'y\')
   {
       //calling the function to add questions and answers into the array
       setQuestionsAndAnswers();
       int i=0;
       char choice;
       do
       {
           cin.ignore();
           string answer = \"\";
           cout<<endl<<questions[i]<<endl;
           getline(cin,answer);
           //converting all the characters of the user entered answer to lower case
           transform(answer.begin(), answer.end(), answer.begin(), ::tolower);
           //comparing the answer provided by the user with the answer in the array
           if(answer.compare(answers[i]) == 0)
           {
               cout<<endl<<\"You are correct!\"<<endl<<endl<<\"Play again (Y/N)? \";
               cin>>choice;
               cout<<endl<<\"--------------------------------------------------------------------------\"<<endl;
               i++;
           }
           else
           {
               cout<<endl<<\"Nice try but no\"<<endl<<endl<<\"Play again (Y/N)? \"<<endl;
               cin>>choice;
               cout<<endl<<\"--------------------------------------------------------------------------\"<<endl;
               i++;
           }
       }while(choice ==\'y\' || choice ==\'Y\');
       cout<<endl<<\"Thanks for playing the Sci-Fi Tv and Movie Trivia Game!\"<<endl;
       cout<<\"Come again soon\"<<endl;
       cout<<endl<<\"--------------------------------------------------------------------------\"<<endl;
   }
   else
   {
       cout<<endl<<\"May be another time...\"<<endl;
       cout<<endl<<\"--------------------------------------------------------------------------\"<<endl;
       cout<<endl<<\"Press any key to continue...\";
   }
   return 0;
}

Write a C++ program that implements a simple TV/movie trivia game. The program begins by welcoming the prospective player to the game, then asks the player if s
Write a C++ program that implements a simple TV/movie trivia game. The program begins by welcoming the prospective player to the game, then asks the player if s
Write a C++ program that implements a simple TV/movie trivia game. The program begins by welcoming the prospective player to the game, then asks the player if s
Write a C++ program that implements a simple TV/movie trivia game. The program begins by welcoming the prospective player to the game, then asks the player if s
Write a C++ program that implements a simple TV/movie trivia game. The program begins by welcoming the prospective player to the game, then asks the player if s
Write a C++ program that implements a simple TV/movie trivia game. The program begins by welcoming the prospective player to the game, then asks the player if s
Write a C++ program that implements a simple TV/movie trivia game. The program begins by welcoming the prospective player to the game, then asks the player if s

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site