Question: Write a Java program that simulates the rolling of 100 dice and stores the tallies of how many 1s, 2s, 3s, 4s, 5s, and 6s

Write a Java program that simulates the rolling of 100 dice and stores the tallies of how many 1s, 2s, 3s, 4s, 5s, and 6s in a six-element array named results. The program should start by displaying the following menu:

DICE ROLLING SIMULATION

=======================

s. Simulate dice rolling

h. Display histogram

q. Quit program

Enter your choice:

When s is entered, the program uses a loop of 100 iterations to simulate the rolling of 100 dice. Every iteration should generate a random number between 1 and 6, and depending on that number increments the correct element on the random the results array. It then displays the above menu. When h is entered, a histogram similar to the following is displayed based on the numbers int he results array and the above menu is displayed again.

1: ********************* (21)

2: ***************** (17)

3: *************** (15)

4: **************** (16)

5: *********** (11)

6: ******************** (20)

If anything other than s, h, or q is entered, the program displays the message Invalid choice before it displays the above menu again. If q is entered, the program terminates.

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!