Concept explainers
Trivia Game
In this
The program will work like this:
• Starting with player 1, each player gets a turn at answering five trivia questions. (There are a total of 10 questions.) 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 of 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.
In this program, you will design a Question class to hold the data for a trivia question.
The Question class should have member variables 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 appropriate constructor(s), accessor, and mutator functions.
The program should create an array of 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.
Want to see the full answer?
Check out a sample textbook solutionChapter 13 Solutions
Starting Out with C++ from Control Structures to Objects (9th Edition)
Additional Engineering Textbook Solutions
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Java: An Introduction to Problem Solving and Programming (8th Edition)
Concepts of Programming Languages (11th Edition)
Database Concepts (8th Edition)
Starting Out with Programming Logic and Design (4th Edition)
- 9. Trivia Game In this programming exercise, you will create a simple trivia game for two players. The program will work like this: Starting 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 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. 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 _…arrow_forward* Question Completion Status: Moving to another question will save this response. Quèstion 5 Simplified form of F=y +x y+y xz is xy + y + x Z xy + y (1 + y z) xy +y (x+y z) xy +y +xz A Moving to another question will save this response.arrow_forwardWord Sleuth Puzzle Programarrow_forward
- check_game_over(): as the name suggests, this function should check to see if the game is over (if one side has no stones left in all of its pockets). It takes as an argument the game board and should return True if the game is over and False otherwise.arrow_forwardOutput Specification The program prints out the total Calories of the selected meal, and stops executing after this output. Sample Input Соpy 1. Sample Output Сopy Your total Calorie count is 649. Explanation The customer chose Burger #2, Side #1, Drink #3 and Dessert #4.arrow_forwardSTART OF PLAY The player starts with 100 points. They have ten attempts (or rounds) to reach 500 points to win. Each round, the player "bets" some amount of points. See gameplay as follows: A HIGH/LOW ROUND (1) The player is shown an initial random card.Cards have a value from 2-14; however, these values are converted to a string as follows: 2-9 are converted to their string equivalent "2", "3", ... "9"10 is "T", 11 is "J", 12 is "Q", 13 is "K" and 14 is "A" (2) After the play sees the first card, they should guess if the next card will be higher (i.e., greater than the current card) or lower (i.e., a lower value than the first card).They will do this by inputting "H" or "L" (lowercase "h" and "l" will also be accepted as valid input). (3) After they input their "high" or "low" guess, the player bets a number of points that their guess will be right. The bet must be between 1 and the total amount of points the player has.1 (4) After the bet amount is entered, a second card will be…arrow_forward
- ne: ID: A 7. A game is played by moving a game piece left or right along a horizontal game board. The board consists of spaces of various colors, as shown. The circle represents the initial location of the game piece. Yellow Black Green Green Red Yellow Yellow Black Black Black The following algorithm indicates how the game is played. The game continues until the game is either won by landing on the red space or lost when the piece moves off either end of the board. Step 1: Place a game piece on a space that is not red and set a counter to 0. Step 2: If the game piece is on a yellow space, move the game piece 3 positions to the left and go to step 3. Otherwise, if the game piece is on a black space, move the game piece 1 position to the left and go to step 3. Otherwise, if the game piece is on a green space, move the game piece 2 positions to the right and go to step 3. Step 3: Increase the value of the counter by 1. Step 4: If game piece is on the red space or moved off the end of the…arrow_forwardAssignment Description This program will simulate part of the game of Yahtzee! This is a dice game that involves rolling five dice and scoring points based on what show up on those five dice. The players would record their scores on a score card, and then total them up, and the player with the larger total wins the game. A Yahtzee score card has two portions: The upper portion has spaces for six scores, obtained by adding up all of the 1's, 2's, 3's, etc. The lower portion has special scores for various combinations: Three of a kind -- at least 3 dice are the same number;the score is the sum of all five dice Four of a kind -- at least 4 dice are the same number;the score is the sum of all five dice Small straight -- four consecutive numbers are represented, e.g. 2345;the score is 25 points Large straight -- five consecutive numbers are represented, e.g. 23456;the score is 30 points Full House -- three of one kind, two of another; the score is 30 points Yahtzee! -- five of a kind; the…arrow_forwardForce Completion This test can be saved and resumed at any polnt until time has expired. The timer will continue to run if you leave the test. Remaining Time: 49 minutes, 11 seconds. * Question Completion Status: A Moving to another question will save this response. « > Question 4 8 points Save Answer (10101)2 xor (10111)2 = (abcde)2 based on the equation calculate ((not b or d) and e). A Moving to another question will save this response. « »arrow_forward
- Number Guessing Game. The program will generate a random number from 1 to 1000. The player will be given several chances to guess the number. The program gives a hint that the given number is lower or higher. If the player's guess is correct, give the player a single point. Tally the number of correct and wrong guesses that the player has made. After every round, display the tally (correct, wrong, and score) After a cycle the program will ask the user if he wants to continue playing. This is a console project. Below source code is my answer with the Question. Kindly check it sir/maam if i have the problem with the code. Thank you using System;using System.Collections.Generic;using System.Text;class Program{static void Main(string[] args){while (true){int randno = Newnum(1, 1001);int count = 1;while (true){Console.Write("Enter a number between 1 and 1000(0 to quit):");int input = Convert.ToInt32(Console.ReadLine());if (input == 0)return;else if (input <…arrow_forwardDirections: The question or incomplete statement below is followed by four suggested answers or completions. Select the one that is best in each case. A student wrote the following code for a guessing game. Line 1: secretNumber RANDOM (1, 100) Line 2: win ← false Line 3: REPEAT UNTIL (win) Line 4: ( Line 5: DISPLAY ("Guess a number.") Line 6: guess INPUT ( ) Line 7: IF (guess = secretNumber) Line 8: ( Line 9: DISPLAY ("You got it right!") Line 10: } Line 11: Line 12: Line 13: ( ELSE IF (guess > secretNumber) Line 14: ( Line 15: DISPLAY ("Your guess is too high.") Line 16: } Line 17: ELSE Line 18: ( Line 19: DISPLAY ("Your guess is too low.") Line 20: } Line 21: } Line 22: } While debugging the code, the student realizes that the loop never terminates. The student plans to insert the instruction win true somewhere in the code. Where could win true be inserted so that the code segment works as intended? Between line 6 and line 7 Between line 9 and line 10 Between line 20 and 21 Between…arrow_forwardQ2 The Powerball Lottery 15 Points The Powerball lottery is based on a random drawing of six balls from two machines. One machine contains 69 white balls (labeled 1 through 69) and the other machine contains 26 red balls (labeled 1 through 26). To determine the winning numbers, the gamemaster draws five white balls from the first machine and one red ball (the "Powerball") from the second machine (assume all outcomes are equally likely). A player in the Powerball lottery picks five different numbers between 1 and 69 (inclusive) and a sixth number between 1 and 26 (inclusive), which may duplicate one of the first five numbers. For each of the following questions, you should write your answer as an expression. Do not give the final numeric value. For example, you should write C(4, 2)/24) instead of 0.375.arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr