Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am trying to write a program that is a trivia game. Start with player 1, each

ID: 3629548 • Letter: I

Question

I am trying to write a program that is a trivia game. Start with player 1, each player gets a turn at answering 5 trivia questions (there are 10 questions total). When a question is displayed, four possible answeres are also displayed. Only one of the answers in correct, and if the player selects the correct answer he or she earns a point. After answers have been selected for all of the questions, the program diplays the number of points earned by each player and declase the player with the highest number of points the winner.Needs to have a Question class to hold the data for a trivia question. The member variables for the data are
a trivia question
possible answers 1-4, the number of the correct answer
There should be an array of 10 question objects (1 for ea. trivia question you make up)

Explanation / Answer

I have this code is for a program similar to the one your asking about I think it can be helpful you can modify it to your requirements //----------------------------------------------------------------- // trivia.h // // Interface file for the Trivia class. #include using namespace std; class Trivia { public: Trivia(); Trivia(string question, string answer, int amount); ~Trivia() {}; string getQuestion(); void setQuestion(string newQuestion); string getAnswer(); void setAnswer(string newAnswer); int getAmount(); void setAmount(int newAmount); private: string question; string answer; int amount; }; // trivia.cpp // // Implementation of the trivia class. Trivia questions objects are // stored in a vector, where each object contains the question, answer, // and dollar amount. // The game iterates over every question, inputs an answer from the // user, and adds to the total score if correct. // The game could be improved by allowing multi-word answers, // removing case-sensitivity, reading from a file // (project from chapter 12) #include #include #include #include "trivia.h" using namespace std; //================================== // Accessors and Mutators Follow //================================== Trivia::Trivia() { question = ""; answer = ""; amount = 0; } Trivia::Trivia(string question, string answer, int amount) { this->question = question; this->answer = answer; this->amount = amount; } string Trivia::getQuestion() { return question; } void Trivia::setQuestion(string newQuestion) { question = newQuestion; } string Trivia::getAnswer() { return answer; } void Trivia::setAnswer(string newAnswer) { answer = newAnswer; } int Trivia::getAmount() { return amount; } void Trivia::setAmount(int newAmount) { amount = newAmount; } // ====================== // main function // ====================== int main() { // Variable declarations vector triviaList; // List of trivia questions Trivia trivia; // One trivia question // ---------------------------------- // --------- BEGIN USER CODE -------- // ---------------------------------- // Load the vector with trivia trivia.setQuestion("What is the 49th state admitted to the USA?"); trivia.setAnswer("alaska"); trivia.setAmount(2); triviaList.push_back(trivia); trivia.setQuestion("Geometric shape most like a lost parrot?"); trivia.setAnswer("polygon"); trivia.setAmount(10); triviaList.push_back(trivia); trivia.setQuestion("Year that Amelia Earhart disappeared?"); trivia.setAnswer("1938"); trivia.setAmount(5); triviaList.push_back(trivia); trivia.setQuestion("Capital of Burundi?"); trivia.setAnswer("bujumbura"); trivia.setAmount(5); triviaList.push_back(trivia); trivia.setQuestion("Fifth president of the United States?"); trivia.setAnswer("james monroe"); trivia.setAmount(7); triviaList.push_back(trivia); // Play the trivia game. Iterate through each question, // ask it, and tally up a total score of winnings. int winnings = 0; cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote