Programming and Computer Science in Java:
Pop Quiz #1:   Random Numbers
    David Kosbie, 2002-2003
See Course Home Page

Quiz Date:  Thu, Mar 20, 2003

Question 1:   You are playing a game with three dice -- one with 5 sides (numbered 1 through 5), one with six sides (numbered 1 through 6) and one with 7 sides (number 1 through 7).  A winning roll has two requirements:

  1. The sum of the values on the three faces is greater than 8.
  2. None of the values on the three faces is prime.

Write a Java program which rolls the three dice 100k times, and uses the results of these 100k rolls in order to estimate the probability of a winning roll.  Print your answer out as a percentage, and use double math in computing your answer for maximal accuracy.

Good luck!


See Course Home Page