Question: To do in Java: Write a driver program named DiceGame that plays a simple dice game between the computer and the user. Each will roll
To do in Java: Write a driver program named DiceGame that plays a simple dice game between the computer and the user. Each will roll only one die. When the program runs, a loop should repeat 100 times. Use a for loop for this. Each iteration of the loop should do the following:
Generate a random integer in the range of 1 through 6. This is the value of the computers roll. See Ex3DiceRoll.java that I included in my module 2 programs for information on how to do this.
Generate another random integer in the range of 1 through 6. This is the value of the users dice.
The die with the highest value wins. (In case of a tie, there is no winner for that particular roll of the dice.)
As the loop iterates, the program should keep count of the number of times the computer wins, the number of times that the user wins, and the number of ties. After the loop performs all if its iterations, the program should display who was the grand winner, the computer or the user and how times each won as well as the number of ties.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
