COMP – 10062 – Programming in Java

Description

Having Trouble Meeting Your Deadline?

Get your assignment on COMP – 10062 – Programming in Java  completed on time. avoid delay and – ORDER NOW

You will define two classes
one to represent a die with an arbitrary number of sides, and one to
represent a collection of dice. Then you will roll the entire collection
repeatedly and use an array to build a histogram of the results. This
assignment uses Standard Input and Output.

A Die object can have any integer number of sides. The number of sides is specified when a Die is
created and cannot be changed. A Die can report its number of sides, can report the side that is
currently showing, and can be rolled. When a die is rolled, it generates and stores a new integer from 1
to n, where n is its number of sides. It has a toString() method that reports the number of sides and the
number that is currently showing. That’s all it can do.
A DiceCollection object holds a set of Die objects in an array. The number of sides on each die is
specified by passing an array of integers to the DiceCollection constructor. This array is used to create
and store the corresponding Die objects. A DiceCollection object can report the current sum of all the
sides showing on the dice, it can report the maximum and minimum possible sums, and it can roll all the
dice at once. It has a toString() method that reports all the dice, the minimum possible roll, the
maximum possible roll, and the current total showing on the dice. That’s all it can do.
The exact details of the implementation and interface of these two objects is up to you, but you must
respect the specifications given above, and you must draw and hand in a UML class diagram to
represent Die, DiceCollection and the association relationship between the two classes.


The Main Method


The main method should start by asking the user
to enter the number of sides of each die. Then it
should present a menu in a loop that allows them
to roll the dice collection once, or 100,000 times
on each iteration. If they choose a single roll,
show the result. If choose 100,000 rolls, create an
integer array of counters (i.e. a histogram) to
keep track of how many times each number got
rolled. Then report the totals.
The main method should do no calculations at all,
outside of adding 1 to the appropriate element of the histogram on each roll.

Example Output

Below is an example output of the program. User input is boldfaced and red. You are free to make your
interface look however you like.

How many dice? 4
Enter the number of sides of each die: 4 4 4 6

Dice Collection: d4=4 d4=1 d4=1 d6=4
Min=4 Max=18 Current=10

1=roll once, 2=roll 100000 times, 3=quit: 1

Dice Collection: d4=1 d4=4 d4=3 d6=3
Min=4 Max=18 Current=11

1=roll once, 2=roll 100000 times, 3=quit: 2
4: 246
5: 1096
6: 2489
7: 5253
8: 8288
9: 11423
10: 13782
11: 14621
12: 13790
13: 11507
14: 8347
15: 5257
16: 2597
17: 1053
18: 251
Dice Collection: d4=1 d4=3 d4=1 d6=4
Min=4 Max=18 Current=9
1=roll once, 2=roll 100000 times, 3=quit: 3
BYE!!!

Optional Extra 1: Here’s a nicer way to display the
histogram, courtesy of Mark Yendt. Scale the numbers
down and print asterisks to represent the quantities.
4: 257
5: 1056 *
6: 2559 ***
7: 5308 *****
8: 8331 ********
9:11303 ***********
10:13788 **************
11:14643 ***************
12:13747 **************
13:11398 ***********
14: 8339 ********
15: 5287 *****
16: 2670 ***
17: 1043 *
18: 271

NOTE: Please make sure it is handwritten as it is a college project. DO NOT use high-level programming use basic programming that helps to reach the output. DO NOT use any AI for written the code.


Explanation & Answer

Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Order Now and we will direct you to our Order Page at Litessays. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

Do you need an answer to this or any other questions?

Similar Posts