Question: Part 3 - Randomly accessing an array Create a new Die object. Create a loop that will iterate 100 times. In the loop body: o

 Part 3 - Randomly accessing an array Create a new Die

Part 3 - Randomly accessing an array Create a new Die object. Create a loop that will iterate 100 times. In the loop body: o Roll the die. Take the result of the roll, map it to the location in the array, and increment that cell of the array. (The die values will be in the range 1 - 6; your array subscripts are 0 5. Think about how you will map the die values to subscripts) o The value of each array element will be a count of the number of times that roll is made. So if 1 comes up three times, array[0] should have the value 3. After the loop finishes, print the results of the rolls as they correspond to die faces. In other words, how many times was a 1 rolled2, 2? etc. For example, if the array holds (20, 17, 19, 15, 12, 17) you would output: 1 was rolled 20 times. 2 was rolled 17 times ***array ->int] array new int[6]; has been made and all values have been initialized with value 0*** (incase the 4th step was confusing)

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!