Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

HELP ASAP! Please this is my 3rd time posting this question. Answer all steps or none. It is a java code(Dice game) and the steps

HELP ASAP! Please this is my 3rd time posting this question. Answer all steps or none.

It is a java code(Dice game) and the steps tells you want to do . import java.util.Random; import java.util.Scanner; public class HistogramCLI { public static void main(String[] args) { boolean again; Scanner scan = new Scanner(System.in); Random rand = new Random(); //

1. Declare some variables: // -6 int variables: dice, sides, rolls, dieSum, // minIndex, maxIndex. Initialize // all these to zero // -A Histogram reference variable by the name "hist" // (just declare -- do not initialize yet!) // -An int array variable by the name "counts" // (just declare -- do not initialize yet!) / NOTE: The remainder of the code will involve several // nested loops. Please pay attention to the // indentation of my comments, to help yourself // keep track of what is nested where //

2. Set up an outer do-while loop, which ends when // the boolean variable "again" is false //

3. A do-while that asks how many dice the user wants // (constrain the user to 1 - 3) and assigns the // resulting value to the variable "dice". //

4. A do-while that asks how many sides each die should have // (constrain the user to 2 - 9) and assigns the resulting // value to the variable "sides". .

Assign values to minIndex and maxIndex, // based on the number of dice and how // many sides each die has.

// 7. Initialize counts to a new int array // with a size of maxIndex plus 1 //

8. Repeatedly roll the dice // --Set "dieSum" back to zero // --For each die, generate a random integer // between 1 and the number of sides, and // add the resulting value to "dieSum" // --Increment the element in the counts array // corresponding to the value of "dieSum" //

5. A do-while that asks how many times to roll the die // (constrain the user to 1000 - 100 million) and assigns the // resulting value to the variable "rolls". . Assign values to minIndex and maxIndex, // based on the number of dice and how // many sides each die has.

// 7. Initialize counts to a new int array // with a size of maxIndex plus 1 //

8. Repeatedly roll the dice // --Set "dieSum" back to zero // --For each die, generate a random integer // between 1 and the number of sides, and // add the resulting value to "dieSum" // --Increment the element in the counts array // corresponding to the value of "dieSum" //

9. Call the Histogram constructor with the variables counts, // minIndex, maxIndex, MAX_LENGTH; and assign the object to hist. // Then, call the drawHor() and drawVer() methods, with lines // skipped in between for neater output

Thank you. Please I need help with it ASAP!

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What physical locations do you work in?

Answered: 1 week ago