Question: use java please Program #5 - Dice Experiment I Directions: 1. Create a new project like so: File -> New Project 2. Select the category

use java please  use java please Program #5 - Dice Experiment I 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

Program #5 - Dice Experiment I 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 i 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). Project Goal The goal of this programming project is to model an experiment in which we will observe the outcomes of rolling ni six-sided dice I 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). I Example Run 1 Example Run 2 Enter number of dice: Enter number of dice: 2 Enter number of rolls: 50000 Results of Experiment 3 Enter number of rolls: 1000 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 B: 91 Roll of 9: 110 Roll of 10: 116 Holl of 11: 129 Roll of 121 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 31 2760 Roll of 41 4183 Roll of 51 5610 Roll of 6: 6904 Roll of 7: 8321 Roll of 81 6842 Roll of 9: 5560 Roll of 10: 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 roll Dice (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. I 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 DiceExperiment public static void main(String] args) { // Your main code here public static int rollsingle 2 public static int rolloice(int n) { 2 public static void printResults(int Il results) ) 18 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. Here are some more suggestions: 1. The user will type in the number of dice using a Scanner. You can use the number of dice to initialize an array to hold the "results" of the experiment. The length of the array should be the number of outcomes of the dice (ie. 1 dice=6 results, 2 dice = 12 results, etc). I HintEssentially, what you need to do is create a frequency table". You a. are tracking the frequency of dice roll outcomes using the index of the array as the number rolled, and the value at that index as the amount of times it was rolled. For example, if you rolled a 5 ten times, index 5 should hold the value 10. 2. Once you have finished the main part of the program, try improving the output. a. You may include a line to notify the user of the most likely dice roll, least likely, etc. b. Below is an example of a slightly better, more readable version of the output that you can try to implement. It's more of a table, which makes the results casier to interpret/understand Enter number of dice: 2 Enter number of rolls: 50000 Results of Experiment Roll 1 Count 21 3 5 6 2 1471 2760 4183 -5610 6904 8321 6842 5560 4221 2729 1399 8 9 10 11 12 1 Most likely roll: 7

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!