Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this programming exercise, you will create a simple trivia game for two players. The program will work like this: Starting out with player 1,

In this programming exercise, you will create a simple trivia game for two players. The program will work like this:

Starting out with player 1, each player gets a turn at answering 5 trivia questions. (There should be a total of 10 questions.) When a question is displayed, 4 possible answers are also displayed. Only one of the answers is correct, and if the player selects the correct answer, he or she earns a point.

After answers have been selected for all questions, the program displays the number of points earned by each player and declares the player with the highest number of points is the winner.

To create this program, write a Question class to hold the data for a trivia question. The Question class should have attributes for the following data:

A trivia question

Possible answer 1

Possible answer 2

Possible answer 3

Possible answer 4

The number of the correct answer (1, 2, 3, or 4)

The Question class also should have an appropriate constructor, accessors, and mutators. The Header file has been included for you to implement.

The program should have an array containing 10 Question objects, one for each trivia question. Make up your own trivia questions on the subject or subjects of your choice for the objects and read Trivia Questions with possible answers and number of the correct answer from an input text file that you create (trivia.txt) in any format.

Sample Output (user input is bold)

Player 1:

What is 1 + 1?

1: 1

2: 2

3: 3

4: 4

Choose an answer by entering a number from 1 to 4.

2

Player 1:

What is 2 + 2?

1: 1

2: 2

3: 3

4: 4

Choose an answer by entering a number from 1 to 4.

1

Player 1:

What is 3 + 3?

1: 2

2: 4

3: 6

4: 8

Choose an answer by entering a number from 1 to 4.

1

Player 1:

What is 4 + 4?

1: 2

2: 4

3: 6

4: 8

Choose an answer by entering a number from 1 to 4.

3

Player 1:

What is 5 + 5?

1: 7

2: 8

3: 9

4: 10

Choose an answer by entering a number from 1 to 4.

2

Player 2:

What is 6 + 6?

1: 12

2: 14

3: 16

4: 18

Choose an answer by entering a number from 1 to 4.

1

Player 2:

What is 7 + 7?

1: 12

2: 14

3: 16

4: 18

Choose an answer by entering a number from 1 to 4.

2

Player 2:

What is 8 + 8?

1: 12

2: 14

3: 16

4: 18

Choose an answer by entering a number from 1 to 4.

3

Player 2:

What is 9 + 9?

1: 12

2: 14

3: 16

4: 18

Choose an answer by entering a number from 1 to 4.

1

Player 2:

What is 10 + 10?

1: 16

2: 18

3: 20

4: 22

Choose an answer by entering a number from 1 to 4.

4

Player 1 scored 1 points

Player 2 scored 3 points

The winner is Player 2

Press any key to continue . . .

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Accounting Simplified For Beginners

Authors: Preston C Wainwright

1st Edition

8550577332, 9798550577332

Students also viewed these Databases questions

Question

305 mg of C6H12O6 in 55.2 mL of solution whats the molarity

Answered: 1 week ago