Answered step by step
Verified Expert Solution
Question
1 Approved Answer
the RollDie.java: import java.util.Random; import java.util.Scanner; /* * HEADER HERE !! */ public class RollDie { public static void main(String[] args) { Scanner scnr =
the RollDie.java:
import java.util.Random; import java.util.Scanner; /* * HEADER HERE !! */ public class RollDie { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); // Step 1: Declare and initialize array and // initialize random number generator int[] rollValueCounts = new int[7]; Random randGen = new Random(); // Step 2: Determine the number of rolls System.out.print("How many times do you want to roll the die?"); System.out.print(" [Max value is 100] "); int numRolls = scnr.nextInt(); // TODO: Check that user provided value is valid // (i.e., in the range 0-100) and if not reprompt System.out.println("Let's get rolling..."); // Step 3: Generate numRolls random values between 1-6 for(int i = 0; i objective: create methods that receive arrays as arguments. Problem Statement: Roll a 6-side die a user specified number of times and keep track of the number of times each value appears. Simulate rolling the die by generating a random number in the range of 1 to 6. After rolling the die the needed number of rolls, display a histogram of the distribution of roll values See the sample output below How many times o you want to ro the die Max value s 1 00 TRY AGAIN! Hou many times do you want to roll the die? [Max value is 100] 15 Let's get rolling The number of 1's 4 The number of 2's The number of 3's The number of 4 The number of 5's: 4 The number of 6's: 2 To begin, create a new project called Lab9-RollDie'. Download and add the Roll Diejava starter code provided on Blackboard
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started