Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise VI - Dice In this problem, you are going to simulating the results of rolling two six-sided dice. Start by creating two classes Die

image text in transcribed

Exercise VI - Dice In this problem, you are going to simulating the results of rolling two six-sided dice. Start by creating two classes Die and DicePair as follows: Die rand Diel) -roll): int DicePair -diei die2 DicePair) -rolll): int . Dice: Private field rand that is an instance of the Random class. Method roll() that returns a random integer between 1 and 6. DicePair: Private fields die1 and die2 that are instances of the Die class. The method roll) that simulates rolling both dice. Write a new class DieRollRun (that has the main method) to perform the following functionality. The program takes 2 input from the command line, an integer n and a file name f. It will then call roll) from the DicePair class n times and store the value of each roll on a separate line in f. Example: > java DiceRoll Run 10 dice-roll-results.txt After running that command the file dice-roll-results.txt has the following output: 10 4 7 9 Page 5 CMPS 212 Lab 05 Spring 2020/2021 12 8 6 7 Note that the results may vary due to the randomness in generating the numbers

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

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions

Question

2. Ask them about their work/life challenges.

Answered: 1 week ago

Question

u = 5 j , v = 6 i Find the angle between the vectors.

Answered: 1 week ago