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

Having issues with my program. Can anyone help out? #ifndef QUESTION_H #define Q

ID: 3659510 • Letter: H

Question

Having issues with my program. Can anyone help out? #ifndef QUESTION_H #define QUESTION_H #include // Question class declaration class Question { private: string ques; string answer1; string answer2; string answer3; string answer4; int correctnum; public: //mutators void Question::setQues(string q) { ques = q; } void Question::setAnswer1(string a1) { answer1 = a1; } void Question::setAnswer2(string a2) { answer1 = a2; } void Question::setAnswer3(string a3) { answer1 = a3; } void Question::setAnswer4(string a4) { answer1 = a4; } void Question::setCorrect(int correct) { correctnum = correct; } //accessors string Question::getQues() const { return ques; } string Question::getAnswer1() const { return answer1; } string Question::getAnswer2() const { return answer2; } string Question::getAnswer3() const { return answer3; } string Question::getAnswer4() const { return answer4; } int Question::getCorrect() const { return correctnum; } }; #endif #include "Question.h" #include #include #include using namespace std; void QuestionAns(Question[], int); int main() { Question trivia[10]; // 10 instances of Game class int count = 0; // Used to count and as index // Variables to hold players answers int onechoice; int twochoice; // Holds total points for each player int int twoPoints = 0; cout << "Let's test your knowledge." << endl; cout << "May the best person win" << endl; // Creates questions and answers in each object // Question One trivia[0].setQues("What military branches make up the Department of Defense? "); trivia[0].setAnswer1("1. Navy"); trivia[0].setAnswer2("2. Air Force"); trivia[0].setAnswer3("3. Army"); trivia[0].setAnswer4("4. All of the above"); trivia[0].setCorrect(4); // Question Two trivia[1].setQues("What is the highest rank you can achieve in the navy as an enlisted member?"); trivia[1].setAnswer1("1. Master Sergeant"); trivia[1].setAnswer2("2. Master Chief Petty Officer of the Navy"); trivia[1].setAnswer3("3. Senior Chief Petty Officer"); trivia[1].setAnswer4("4. Senior Master Sergeant"); trivia[1].setCorrect(2); // Question Three trivia[2].setQues("What is the highest rank you can achieve in the Navy as an officer?"); trivia[2].setAnswer1("1. 4 star Admiral"); trivia[2].setAnswer2("2. 3 star Admiral"); trivia[2].setAnswer3("3. 4 star General"); trivia[2].setAnswer4("4. 3 star General"); trivia[2].setCorrect(1); // Question Four trivia[3].setQues("Which Department of Defense branch has more ships than the Navy?"); trivia[3].setAnswer1("1. Coast Guard"); trivia[3].setAnswer2("2. Merchant Marines"); trivia[3].setAnswer3("3. Army"); trivia[3].setAnswer4("4. Air Force"); trivia[3].setCorrect(3); // Question Five trivia[4].setQues("The official date the Navy was established was?"); trivia[4].setAnswer1("1. June 14, 1775"); trivia[4].setAnswer2("2. November 10, 1775"); trivia[4].setAnswer3("3. October 13, 1775"); trivia[4].setAnswer4("4. September 18, 1947"); trivia[4].setCorrect(3); // Question Six trivia[5].setQues("The Navy's newest Aircraft Carrier is the ?"); trivia[5].setAnswer1("1. USS George H. W. BUSH "); trivia[5].setAnswer2("2. USS Ronald Reagan"); trivia[5].setAnswer3("3. USS Harry S. Truman"); trivia[5].setAnswer4("4. USS John C. Stennis"); trivia[5].setCorrect(1); // Question Seven trivia[6].setQues("Which of teh following Aircraft Carriers were commissioned in 1961 and saw the Cuban Missile Crisis?"); trivia[6].setAnswer1("1. USS Nimitz"); trivia[6].setAnswer2("2. USS Enterprise"); trivia[6].setAnswer3("3. USS Forrestal"); trivia[6].setAnswer4("4. USS Carl Vinson"); trivia[6].setCorrect(2); // Question Eight trivia[7].setQues("Which of the following ships is notable for using steel that was salvaged from the World Trade Center, after it was destroyed in the September 11 attacks.?"); trivia[7].setAnswer1("1. USS Alameda"); trivia[7].setAnswer2("2. USS San Antonio"); trivia[7].setAnswer3("3. USS New York"); trivia[7].setAnswer4("4. USS Dallas"); trivia[7].setCorrect(3); // Question Nine trivia[8].setQues("Which Deparment of Defense component falls under the Department of the Navy"); trivia[8].setAnswer1("1. Marine Corps"); trivia[8].setAnswer2("2. Air Force"); trivia[8].setAnswer3("3. Army"); trivia[8].setAnswer4("4. Coast Guard"); trivia[8].setCorrect(1); // Question Ten trivia[9].setQues("Which federal agency handles crimes aginst the U.S. Navy and Marine Corps"); trivia[9].setAnswer1("1. FBI"); trivia[9].setAnswer2("2. CIA"); trivia[9].setAnswer3("3. NCIS"); trivia[9].setAnswer4("4. DEA"); trivia[9].setCorrect(3); // Start while loop for the game while(count < 9, count++) { cout << setw(10) << " QUESTION " << (count + 1) << endl; questionAns(trivia,count); cout << "Player 1's answer: "; cin >> onechoice; cout << "Player 2's answer: "; cin >> twochoice; // If statements check to see if answers are right, if they are right then they get a point if(trivia[count].getCorrect() == onechoice) { onePoints++; } if(trivia[count].getCorrect() == twochoice) { twoPoints++; } cout << endl << endl; } if ( twoPoints) cout << "Both players were tied." << endl; if ( onePoints > twoPoints) cout << "Player one wins!" << endl; else cout << "Player two wins!" << endl; cout << "Thanks for playing."; } void questionAns(Question z[], int count) { cout << z[count].getQues() << endl; cout << z[count].getAnswer1() << endl; cout << z[count].getAnswer2() << endl; cout << z[count].getAnswer3() << endl; cout << z[count].getAnswer4() << endl; }

Explanation / Answer

http://www.cplusplus.happycodings.com/Games/index.html study this link .It has a lot of example programs.

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