Question: JAVA create a main() method In a method do the following: Roll 2 six sided dice 36 times, and store the results in a Hashtable
JAVA
create a main() method
In a method do the following:
Roll 2 six sided dice 36 times, and store the results in a Hashtable
After the dice are rolled, report the results in a histogram
for each line print the result, and the number of times the result was rolled
For example, if a "4" was rolled 6 times, the line would look like this:
4: ******
You can do this in the main() method.
You can use the ThreadLocalRandom class to get random numbers. Try using ThreadLocalRandom.current().nextInt(1, 7);
you will create a DiceRoller class that is a Singleton. The DiceRoller class will include the following methods:
public int rollDice( int numberOfSides, int number OfDice );
You will need to include the constructor, and make it private
You will need to include a getInstance() method
create a main() method
In a method do the following:
Roll 2 six sided dice 36 times, and store the results in a Hashtable
After the dice are rolled, report the results in a histogram
for each line print the result, and the number of times the result was rolled
For example, if a "4" was rolled 6 times, the line would look like this:
4: ******
You can do this in the main() method.
You can use the ThreadLocalRandom class to get random numbers. Try using ThreadLocalRandom.current().nextInt(1, 7);
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
