Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IT IS URGENT HELP PLEASE!! I have die and dice classes. public class Die { private int faceValue; public Die(){ faceValue = 0; } public

IT IS URGENT HELP PLEASE!!

I have die and dice classes.

public class Die { private int faceValue; public Die(){ faceValue = 0; } public int getfaceValue() { return faceValue; }

public int roll() { faceValue = (int) (Math.random() * 6) + 1; return faceValue; } public String toString() { String result = "" + faceValue; return result; } }

public class Dice { private Die die1; private Die die2; private String result;

public Dice() { die1 = new Die(); die2 = new Die(); } public int roll() { return die1.roll() + die2.roll(); } public int getDie1FaceValue() { return die1.getfaceValue(); } public int getDie2FaceValue() { return die2.getfaceValue(); } public int getDieTotal() { return die1.getfaceValue() + die2.getfaceValue(); } public String toString() { result = "die1 = " + die1 + " "+ "die2 = " + die2; return result; } }

Now I need to write a program using ArrayList to create a rough(textual) vertically-oriented histogram of the frequency distrubition produced by rolling a die object 1000 times. Scale your histogram so it fits in maximum 10 lines,regardless of the number of times the dice is rolled.

In more detail : Each roll of dice give numbers between 2-12. Do that 1000 times. Then counting the number of 2's 3's 4's etc. From those carts draw a vertically-oriented bar chart where the first column represents number of 2's the second is 3's the third is 4's etc. If you didn't scale the chart it would properly be about 200 lines but the question asks you to fit it in maximum 10 lines(whether you roll the dice 100 or 1000 times). There is an example for it and the maximum count is 176 so each star represents a count of (176/10) about 18. ~ the columns represent the values between 2-12. Use two static methods. One for create and return the frequency data and other one is for print the data in the form of a histogram. There is a hint which is use an ArrayList to pass the data from one method to the other one.

Frequency Distribution for 1000 Dice rolls ( max freq is 176 ) * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 

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

Recommended Textbook for

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions

Question

What is topology? Explain with examples

Answered: 1 week ago

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago