Answered step by step
Verified Expert Solution
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
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
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