Question
Lets roll some dice! Write a program that allows the user to choose to roll between 1 and 100 dice between 1 and 1000 times.
Let’s roll some dice! Write a program that allows the user to choose to roll between 1 and 100 dice between 1 and 1000 times.
The program should simulate each roll of the die/dice by generating one random number in the range of possible values for the specified number of dice. For example: for 1 die generate one random number between 1 and 6; for 4 dice generate one random number between 4 and 24.
The program should use an array to keep count of the number of times each possible total is rolled. For example, if rolling 1 die the array values will represent how many times a 1 is rolled, how many times a 2 is rolled, how many times a 3 is rolled, how many times a 4 is rolled, how many times a 5 is rolled, how many times a 6 is rolled….if rolling 3 dice, the array values will represent how many times a 3 through 18 is rolled. (Note: the array does not store the values that are being rolled – instead each value in the array contains a count of how many times the value associated with the index has been rolled)
After all the rolls are complete the program should print the results in a histogram where each roll is represented by a *. The histogram should be printed to the screen and to a file. The program should contain a separate method that is used to print out the histogram.
Below the histogram, the program should print out a statement indicating which number or numbers was rolled the most. The program should contain a separate method to determine these results.
The user should be able to “play” as many times as they like.
Step by Step Solution
3.39 Rating (152 Votes )
There are 3 Steps involved in it
Step: 1
Java Code Import javautil class RandomDiceHistogram Public static void master argument s...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Document Format ( 2 attachments)
606ad56865331_49282.pdf
180 KBs PDF File
606ad56865331_49282.docx
120 KBs Word File
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started