Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

We want a program that generates a simple histogram based on the roll of a single die. Write an error-free Java program to do the

image text in transcribed
image text in transcribed
We want a program that generates a simple histogram based on the roll of a single die. Write an error-free Java program to do the following things. Generate 50 random numbers that are integers from 1 to 6. (It is best to use a loop to generate the numbers.) The program only needs to generate one random number at a time. The number represents a simulated die roll. Use an array to count how many times each die roll occurs. Display how many times each die roll occurred. That is, display how many times a 1 happened, a 2 happened, etc . Determine which die roll occurred most often. One can ignore ties; that is, if two or more numbers occur the same amount, just specify one of the numbers . Determine which die roll occurred most often. One can ignore ties; that is, if two or more numbers occur the same amount, just specify one of the numbers Sample output: Number of 1 die rolls-6 2 2 Number of 2 die rolls 15 Number of 3 die rolls = 5 Number of 4 die rolls-6 Number of 5 die rolls-10 2 Number of 6 die rolls 8 PIF . 2 had the most simulated tosses

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

Students also viewed these Databases questions