/* Rolls two dice until a sum of 7 is reached. 2 + 4 = 6 3 + 5 = 8 5 + 6 = 11 1 + 1 = 2 4 + 3 = 7 You won after 5 tries! */ import java.util.*; public class Dice { public static void main(String[] args) { Random rand = new Random(); int sum = 0; int die1 = 0; int die2 = 0; int count = 0; while (sum != 7) { die1 = rand.nextInt(6) + 1; die2 = rand.nextInt(6) + 1; sum = die1 + die2; System.out.printf("%d + %d = %d\n", die1, die2, sum); count++; } System.out.print("You won after " + count + " tries!"); } }