This program will be a Java class entitled: DiceGame
Write code that plays a simple dice game between you and the computer. The dice you will be simulating will have 12 sides instead of the usual 6. When writing the rand.nextInt(n) statement, (with n being a number), be sure you put the correct number in there for a 12-sided die, and be sure to add a 1 to it. rand.nextInt(n) will give you a number between 0 and (n - 1), so you need to add a 1 to the result to get a number between 1 and n.
Each player has in his/her possession an unbiased, 12-sided die. Be CAREFUL! When the program runs, a loop should repeat 25 times. (You must use a for loop for this to get credit!) Each iteration of the loop should do the following:
Here is an example of ONE of the TWENTY-FIVE (25) rounds total that will be played:
Computer Turn Round #1
- - - - - - - - - - - - - - - -
Roll: 6
User Turn Round #1
- - - - - - - - - - - - - - - -
Roll: 10
The difference between the rolls is 4.
The user wins this round!
Here is an example of how the program could finish: (You can make it look prettier if you like.)
Total Number of Computer Wins: 11
Total Number of User Wins: 13
Total Number of Tie Games: 1
The User wins the game!
The purpose of this assignment:
Roadmap:
1. Create a class called DiceGame with a main method. All your code (except imports) will be in the main method.
2. Declare variables to count user wins, computer wins, and ties.
3. Declare and initialize a random number generator. You will need to import java.util.Random.
4. Make a for loop that will iterate 25 times. Steps 5 through 8 will be in this for loop.
5. Calculate the computer's roll and store it in a variable by calling rand.nextInt(12) and adding 1 to it, and print it out.
6. Calculate the user's roll of the 12-sided dice like you did the computers, and print it out.
7. Print out the difference between the two rolls using the Math.abs function to make sure you don't print a negative number.
8. Print out who won the round.
9. Print out how many rounds the computer won, how many the user won, and how many ties there were, and appropriate message for who won overall. (Or if it was a tie.)