Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In java please, while following instructions carefully! If you could also leave comments, that would be greatly appreciated! Thank you!! Write a program called DiceRolls

In java please, while following instructions carefully! If you could also leave comments, that would be greatly appreciated! Thank you!!

image text in transcribed

Write a program called DiceRolls that simulates multiple rolls of two 6-sided dice (use two random numbers for this) and computes the percentage of the total number for each possible outcome. The program should ask the user how many times to roll the dice and use a loop to simulate that many rolls. The program must use an int array to keep track of how many times each possible roll (i.e., 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, and 12) occurs. You may also find it convenient to use double arrays to handle the observed and expected percentages. After all the "rolls" have been performed, determine what the actual observed percentage of the total number of rolls was for each number. For example, if the dice were rolled 500 times and the value 8 was observed 62 times, then the observed percentage would be 12.40%. However, the expected percentage for 8 is 13.89% (5 out of 36 rolls)-you can find the percentages for other rolls onlin at several websites, e.g., (http://boardgames.about.com/od/dicegames/a/probabilities.htm). For each possible roll, display the roll value, the observed percentage, and the expected percentage. Display the results to the console as a table, aligning the results in nice even columns using the printf method. For example: Enter the number of rolls to be simulated: 1300 The percentages observed for 1300 rolls: roll observed expected 2.83% 6.00% 8. 12% 2. 78% 5. 56% 8.33% 4 12 2. 51% 2.78%

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

Students also viewed these Databases questions