Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Directions: 1. Create a new project like so: File -> New Project 2. Select the category Java with Ant and the project Java Application, and

image text in transcribed
image text in transcribed
Directions: 1. Create a new project like so: File -> New Project 2. Select the category Java with Ant and the project Java Application, and hit Next. 3. Name the project DiceExperiment, and make sure the box at the bottom for "Create Main Class" is checked off. 4. In the project sidebar, find DiceExperiment -> Source Packages -> diceexperiment a. In this package, you will find the file in which you will be doing your coding- "DiceExperiment.java" Project Goal The goal of this programming project is to model an experiment in which we will observe the outcomes of rolling n six-sided dice t times. While rolling dice a few times is something we can easily do ourselves, our program will be able to simulate the results of rolling any number of dice any number of times. For example, we can see the distribution of rolling 3 dice 1000 times, or rolling 2 dice 50000 times (shown below). Example Run 1 Example Run 2 Enter number of dice: 2 Enter number of dice: 3 Enter number of rolls: 1000 Results of Experiment Enter number of rolls: 50000 Results of Experiment Roll of 3: 5 Roll of 4: 13 Roll of 5: 20 Roll of 6: 40 Roll of 7: 71 Roll of 891 Roll of 9: 110 Roll of 10: 116 Roll of 11: 129 Roll of 12: 130 Roll of 13 121 Roll of 14: 70 Roll of 15:37 Roll of 16:30 Roll of 17+ 14 Roll of 18: 3 Roll of 2: 1471 Roll of 3: 2760 Roll of 4: 4183 Roll of 5: 5610 Roll of 6: 6900 Roll of 7: 8321 Roll of 8:6842 Roll of 9: 5560 Roll of 101 4221 Roll of 11, 2729 Roll of 12 1399 Implementation Instructions / Requirements You will write your code in the Java file DiceExperiment.java. You should decide how to break down your code, but I would advise you to not have all of it be in the main method. It is very useful to write some static methods to help you accomplish certain tasks. For example, you could consider creating a method called rollSingle () that returns the result of rolling 1 die. You could then create a method called rollDice (int n) that takes in the number of dice to roll, and then uses rollsingle() to add up the sum of however many rolls you need. It could also be helpful to create a method called printResults() that, given an array, would print out the results of the array in the format you can see in the examples above. This is one way to set up your code- you have your main method to handle user input, variable creation, and just running the experiment in general, and then you have helper methods below to handle certain tasks: package diceexperiment: public class Dice Experiment public static void main(String[] args) { W Your main code heret ) public static int rollsingle 2 public static int roltaicoint X public static void printResults(int il results 3 ) You must use loops (either "for" or "while") to run the trials of the experiment, an array to store the results, and Math.random() to generate the random dice rolls

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

Spatial Databases With Application To GIS

Authors: Philippe Rigaux, Michel Scholl, Agnès Voisard

1st Edition

1558605886, 978-1558605886

More Books

Students also viewed these Databases questions

Question

What are the stages of project management? Write it in items.

Answered: 1 week ago

Question

why do consumers often fail to seek out higher yields on deposits ?

Answered: 1 week ago