Question
Main topics: User validated input if & if - else Statements Loop Statements Program Specification: Write a program that allows a single Player (the user)
Main topics: User validated input if & if - else Statements Loop Statements Program Specification: Write a program that allows a single Player (the user) to play a simple four dice game of chance against The Odds. Game Description: There is a single player, with four six sided die. The sides of each die are labeled with the numbers from 1 to 6, we will call this the value of the die. A game is made up of rounds, a single round is played as such: 1. The player rolls their four dice: d1 = (int)(Math.random() * 6) + 1; d2 = (int)(Math.random() * 6) + 1; d3 = (int)(Math.random() * 6) + 1; d4 = (int)(Math.random() * 6) + 1; d1, d2, d3, d4 declared as type int before the game loop. 2. The dice are displayed, in some reasonable format. 3. The user is given the option to re-roll (upto two of their dice) and specify exactly which die they wish to re-roll. 4. The dice are displayed, in some reasonable format. 5. A determination is made as to whether or not the player won the round, this determination is made via the following rules: A Quad is when all the dice have the same number on their top faces. If the player has any Quad then they receive 108 wins. A Triple is when exactly three of the dice have the same number on their top faces. If the player has any Triple then they receive 6 wins. A Two-Pair is when exactly two dice have the number n1 on their top faces and exactly two dice have the number n2 on their top faces n1 6= n2. If the player has any Pair then they receive 4 wins. A Junker is then anything that is not a listed above If the player has any Junker then they receive 1 lose. 6. The result of the round (with respect to the Player) is reported. The player is asked if they wish to play another round. Once the player indicates that they do not wish to play another round: Before exiting, the program displays a short report stating how many rounds were played, how many were wins and how many loses the player received. Grading: Performance Indicator [1] [2] [3] Readability and documentation 0 1 1 Use of if statements 1 2 2 Use of while loops 1 2 2 Functional requirements 2 3 4 Efficiency 0 1 1 Sample run(s): Welcome to Computer Dice ------------------------------------- You will first roll your dice You then are allowed to re-roll upto two of your dice Finally the outcome of your roll is be determined: any Quad and you receive 108 Wins any Triple and you receive 6 wins any Two-Pair and you receive 4 Wins anything else and you receive 1 Lose ------------------------------------- Player ---------- 1 6 2 4 Please enter the number of diceto re-roll [0, 2] : 2 Please enter the number of the die to re-roll [1, 4] : 1 Please enter the number of the die to re-roll [1, 4] : 3 Player ---------- 2 6 6 4 Junker - Sorry, you lose! Do you wish to play again [y, n] : y Player ---------- 4 6 6 5 Please enter the number of diceto re-roll [0, 2] : 2 Please enter the number of the die to re-roll [1, 4] : 1 Please enter the number of the die to re-roll [1, 4] : 4 Player ---------- 3 6 6 2 Junker - Sorry, you lose! Do you wish to play again [y, n] : y Player ---------- 3 4 6 6 Please enter the number of diceto re-roll [0, 2] : 2 Please enter the number of the die to re-roll [1, 4] : 1 Please enter the number of the die to re-roll [1, 4] : 2 Player ---------- 6 6 6 6 Quad - Congrats, you win! Do you wish to play again [y, n] : n Computer Dice Results --------------------- You played 3 rounds Wins :108 Loses :2 ---------------------
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started