In JAVA Write a program that simulates a simple dice game between the computer and the user. When the program runs, a loop should run 5 times; in each iteration, the program should • Generate a random integer in the range of 1 to 6 --this is the value of the computer’s die. • Generate another random integer in the range of 1 to 6 --this is the value of the user’s die. 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 count the number of times the computer wins and the number of times the user wins. In the end, the program should display who was the grand winner, the computer, or the user. The program should perform input validation for the player’s input (only ‘y’ or ‘n’ are acceptable).
In JAVA
Write a
program runs, a loop should run 5 times; in each iteration, the program should
• Generate a random integer in the range of 1 to 6 --this is the value of the computer’s die.
• Generate another random integer in the range of 1 to 6 --this is the value of the user’s die.
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 count the number of times the computer wins
and the number of times the user wins. In the end, the program should display who was the grand
winner, the computer, or the user. The program should perform input validation for the player’s
input (only ‘y’ or ‘n’ are acceptable).
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images