Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Learning Purpose: Practice I Random number generation Use of arrays Sample Output: Sum Frequency Percentage 2 1003 3 1980 4 2955 5 4123 6
Learning Purpose: Practice I Random number generation Use of arrays Sample Output: Sum Frequency Percentage 2 1003 3 1980 4 2955 5 4123 6 4908 7 6014 8 4940 9 3932 10 3100 2034 1011 OH Formatted output 11 12 2.8% 5.5% 8.2% 11.5% 13.6% 16.7% 13.7% 10.9% 8.6% 5.7% 2.8% Instructions: 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 roll the 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 every sum 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 only one way to roll a sum of 12. 191 M 1 2 3 4 5 6 7 3 4 5 6 7 8 3 4 5 6 7 8 9 5 5 6 7 8 9 10 5 6 7 8 9 10 11 7 00 8 10 11 12 Roll the two dice 36,000 times. Display the results in a tabular format like in the sample output. Start with a header line (Sum, Fequency, and Percentage) and list the numbers in right aligned columns. The percentage should display only one digit after the decimal point. In order to output % within a format string write %% Tip: Check whether the results are reasonable (e.g. the sum 7 should be rolled about 1/6 of the time)
Step by Step Solution
★★★★★
3.41 Rating (148 Votes )
There are 3 Steps involved in it
Step: 1
Program import javautilRandom public class Dice public static void mainString args variable declarat...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