/* CSE 142, Autumn 2007, Marty Stepp This version of our dice program is shorter because it uses a do/while loop. */ import java.util.*; // for Random public class Roll2 { public static void main(String[] args) { Random randy = new Random(); // two ints, one for each of two dice [1, 6] int die1, die2; int tries = 0; do { // roll die1 = randy.nextInt(6) + 1; die2 = randy.nextInt(6) + 1; System.out.println(die1 + " + " + die2 + " = " + (die1 + die2)); tries++; } while (die1 + die2 != 7); System.out.println("You won after " + tries + " tries!"); } }