Program that simulates rolling two dice


Basic Requirements:

Question: Write a program that simulates rolling 2 dice and keeps track of the results. The task can be completed by using an Array Lists rather than regular Array’s.

1) Declare an Array List of size 11 to track rolls 2-12. (an unsorted Array List)

2) Ask how many rolls are to be performed

3) Create 2 random numbers, each between 1 and 6 to simulate the dice

4) Fill each elements in the Array List with total of the 2 dice.

5) Store the number of rolls of 2 in the first element, 3 in the second, 4 in the third, etc up to 12 in the 11th element.

6) Print a table showing the rolls, historical and percentage of total rolled (see sample).

7) After the table, print a total row which calculates the total rolls and the total percentage. Ensure to calculate these values and don’t just hard code based on number of rolls at the top.

8) Ensure the dashed line under historical is only as long as the value below it (see example below).

o Hint: You can use the Integer wrapper class to convert the integer to a

9) Finally, print out which roll was rolled most and how many times it was rolled. (Seem sample)

o Hint: Use the collections class to search for the max value in your arrayList string and then determine the length of it.

Sample output is provided below. Be sure to mimic it exactly except for the number of rolls, historical, and percentage which will change.

Sample:

Your output will vary based on the number of rolls entered.

2159_Rolling outcomes of 2 dice.jpg

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Program that simulates rolling two dice
Reference No:- TGS01238043

Expected delivery within 24 Hours