Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What is the code in Java? USE ARRAYS and Random # generator Follow instructions carefully. Keep code simple and easy to read. Use a static

What is the code in Java? USE ARRAYS and Random # generator

Follow instructions carefully. Keep code simple and easy to read.

Use a static method that can be put/getted into the Main method if possible.

Simulate the rolling of 2 dice, roll them both 36,000 times, calculate the sum of both values, use a one-dimensional integer array to count how often the sum appears, so the sum will always be between 2-12, there are 3 ways to roll a sum 4, 6 ways to roll a sum of 7, and only one way to roll a sum of 12, Display the results in tabular format like below. READ FULL INSTRUCTIONS BELOW.

image text in transcribed

CS1400 A09 - Dice Instructions: Learning Purpose: Practice Random number generation Create a new Java file called Dice.java Use of arrays Formatted output 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. Sample Output: Sum Frequency Percentage 2.8% 5.58 8.2% 1003 1980 2955 4123 4908 6014 4940 3932 3100 2034 1011 13.6% 16.7 13.7% 10.9 3 8.6% 578 2.8% 1.0 1.2 10 10 11 789 111 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

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David Kroenke

11th Edition

0132302675, 9780132302678

More Books

Students also viewed these Databases questions

Question

Describe some of the key provisions of the Credit CARD Act.

Answered: 1 week ago