Dice - public static void main(String args int die1 die2...

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

View Full Document Right Arrow Icon
//************************************************************** // Dice.java // // Simulates the rolling of a pair of dice. //************************************************************** import java.util.Random; public class Dice { //----------------------------------------------- // Rolls two die by generating two random numbers // in the range 1 - 6. //-----------------------------------------------
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) { int die1, die2; int totalRoll; Random generator = new Random(); die1 = generator.nextInt(6) + 1; die2 = generator.nextInt(6) + 1; totalRoll = die1 + die2; System.out.println(); System.out.println ("You rolled " + die1 + " and " + die2 + " for a total of " + totalRoll + "."); System.out.println(); } }...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online