// CSE 142, Summer 2008 (Helene Martin) // Rolls two dice until the sum of the numbers rolled is 7. import java.util.*; // CSE 142, Summer 2008 (Helene Martin) // Rolls two dice until their sum is 7. // do-while loop version public class Roll { public static void main(String[] args) { Random r = new Random(); int sum; int count = 0; do { int die1 = r.nextInt(6) + 1; int die2 = r.nextInt(6) + 1; sum = die1 + die2; count++; System.out.println(die1 + " + " + die2 + " = " + sum); } while(sum != 7); System.out.println("You won after " + count + " tries!"); } }