This is the whole program from the book, sorry for such a long post Starting wit
ID: 3535938 • Letter: T
Question
This is the whole program from the book, sorry for such a long post
Starting with player 1, each player gets a turn at answering 5 trivia questions. (there are a total of 10 questions, 5 for each player.)
When a question is displayed, four 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 the questions, the program displays the number of points earned by each player and declares the player with the highest number of points the winner.
You are to design a question class to hold the data for a trivia question. The question class should have fields 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 should have appropiate constructors accessors and mutator methods,
implement a 2D array that keeps the the players' answers (2 players, 5 questions each).
Display the 2D array with player's answers and then display the 2D array of correct answers for each question.
Finally, display the points for each player and the player who won.
Explanation / Answer
// FIRST CLASS //Question class public class Question { // Constant for the number of questions public final int NUM_QUESTIONS = 10; // The trivia question private String questionText; // An array to hold possible answers. private String possibleAnswers[] = new String[NUM_QUESTIONS]; // The number (1, 2, 3, or 4) of the correct answer. private int correctAnswer; //Constructor public Question() { // Initialize all fields to "" or 0; questionText = ""; correctAnswer = 0; for (int i = 1; iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.