Question
Create a new Java file called Dice.java Simulate the rolling of 2 dice. Do that by creating one single object of type Random and by
Create a new Java file called Dice.java
Simulate the rolling of 2 dice. Do that by creating one single object of type Random and by reusing it to rollthe first die and then the second die.
Once both dice have been rolled calculate the sum of the two values.
Use a one-dimensional integer array to count how often each sum appears.When rolling two dice the sum will be a value from 2 12. However, not everysum has the same probability of being rolled. E.g.: There are three ways to roll a sum of 4, six ways to roll a sum of 7 but onlyone way to roll a sum of 12.
Roll the two dice 36,000 times.
Display the results in a tabular format like in the sample output. Start with aheader line ( Sum, Fequency, and Percentage) and list the numbers in rightaligned columns. The percentage should display only one digit after the decimal point. Hint: In order to output % within a format string write %%Recommendation: Check whether the results are reasonable (e.g. the sum 7 should be rolled about 1/6 of the time)
Sample output: Sum Frequency Percentage 1003 2.8% 1980 5.5% 2955 8.2 11.5 4123 4908 13.6% 6014 16.7 4940 13.7 3932 10.9 3100 10 8.6% 5.7 11 2034 12 1011 2.8%Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started