
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Instructions for a java coding exercise where students are required to write a code segment to roll two dice 1000 times and keep track of the number of times the first die rolls larger, the second die rolls larger, and when both dice roll the same number. The document also suggests modifications to roll the dice until one or both dice have rolled larger a specific number of times.
Typology: Assignments
1 / 1
This page cannot be seen from the preview
Don't miss anything!

Write a segment of Java code that repeatedly rolls two dice, keeping the following statistics:
Your code segment should roll the pair of dice 1000 times, and produce the following output.
Die 1 had larger roll ??? times Die 2 had larger roll ??? times Two dice had same roll ??? times
You may assume that you have available the Dice class that we have defined previously (which of course has the roll() method).
How would you change your code to repeatedly roll the dice until one of the two dice has had the larger roll 500 times? What about until both dice have had the larger roll 500 times?
Protocol