BoxCars -...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//******************************************************************** // BoxCars.java Author: Lewis and Loftus // // Solution to Programming Project 4.3 (page xxx). //******************************************************************** public class BoxCars { //----------------------------------------------------------------- // Rolls a pair of dice multiple times, counting the number of // box cars (two sixes) that occur.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: //-----------------------------------------------------------------public static void main (String args) { final int ROLLS = 1000, TARGET = 12; int total, count = 0; PairOfDice dice = new PairOfDice(); for (int roll=1; roll <= ROLLS; roll++) { total = dice.roll(); if (total == TARGET) count++; } System.out.println ("Number of rolls: " + ROLLS); System.out.println ("Number of Box Cars: " + count); } }...
View Full Document

Ask a homework question - tutors are online