Question: Write a Java class that simulates rolling dice. The class should contain two methods,roll and main, As follows: int roll() This method should use the
Write a Java class that simulates
rolling dice. The
class
should contain two methods,roll and main,
As follows:
int
roll()
This method should use the
Random
class
from the Java library to simulate
rolling a die by generating a
random number. It should return the value
rolled, an integer
from 1 to 6 (dont print here)
main
This method
should simulate rolling the die
20 times. It should call the
Roll method 20 times and print out each roll.
It should also calculate & print the average roll as a double.
Do not make
The roll method static
Create an object variable of your class in the main method to call the roll method
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
