Question: Java Programming Please just focus on these main topics. We haven't learned anything past these topics. It can not have any complex things in it.
Java Programming
Please just focus on these main topics. We haven't learned anything past these topics. It can not have any complex things in it. Thanks!!
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:
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.
The dice are displayed, in some reasonable format.
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 win the round.
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 win the round.
A Straight is when the numbers on the four dice faces can be arranged to form a consecutive sequence like 1 2 3 4 or 3 4 5 6 If the player has any Straight then they win the round.
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 = n2. If the player has any Pair then they win the round.
A Pair is when any (exactly) two dice have the same number on their top faces. If the player has any Pair then they neither win nor lose the round.
A Junker is then anything that is not a listed above If the player has any Junker then they lose the round.
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, of those - how many were won and how many were lost.
Sample run(s):
Welcome to Computer Dice ------------------------------------- You will first roll your dice
Next the outcome of your roll will be determined:
any Quad and you Win any Triple and you Win any Straight and you Win any Two-Pair and you Win any Pair and you just roll again anything else and you Lose -------------------------------------
Player ---------- 1456
Junker - Sorry, you lose!
Do you wish to play again [y, n] : 6 Do you wish to play again [y, n] : sure Do you wish to play again [y, n] : y
Player ---------- 1255
Pair - Its a push! Do you wish to play again [y, n] : y
Player ---------- 3345
Pair - Its a push! Do you wish to play again [y, n] : y
Player ---------- 1366
Pair - Its a push! Do you wish to play again [y, n] : y
Player ---------- 3334
Trip - Congrats, you win! Do you wish to play again [y, n] : y
Player ---------- 2566
Pair - Its a push! Do you wish to play again [y, n] : y
Player ---------- 2223
Trip - Congrats, you win! Do you wish to play again [y, n] : y
Player ---------- 3336
Trip - Congrats, you win! Do you wish to play again [y, n] : y
Player ---------- 1336
Pair - Its a push! Do you wish to play again [y, n] : y
Player ---------- 1245
Junker - Sorry, you lose! Do you wish to play again [y, n] : y
Player ---------- 1245
Junker - Sorry, you lose! Do you wish to play again [y, n] : y
Player ---------- 1446
Pair - Its a push! Do you wish to play again [y, n] : y
Player ---------- 1234
Straight - Congrats, you win! Do you wish to play again [y, n] : y
Player ---------- 1335
Pair - Its a push!
Do you wish to play again [y, n] : y
Player ---------- 2345
Straight - Congrats, you win! Do you wish to play again [y, n] : y
Player ---------- 2226
Trip - Congrats, you win! Do you wish to play again [y, n] : y
Player ---------- 3444
Trip - Congrats, you win! Do you wish to play again [y, n] : y
Player ---------- 1245
Junker - Sorry, you lose! Do you wish to play again [y, n] : y
Player ---------- 3355
Two-Pair - Congrats, you win! Do you wish to play again [y, n] : n
Computer Dice Results --------------------- You played 19 rounds
Rounds won :8 Rounds lost :4 ---------------------
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
