// Allison Obourn, CSE 142 // Simulates rolling two dice until their sum is 7. // Prints out the roll combinations and, at the end, // the number of tries it took to get a 7. import java.util.*; public class RandomDemo { public static void main (String[] args) { Random rand = new Random(); int tries = 0; int sum = 0; while(sum != 7){ int roll1 = rand.nextInt(6) + 1; int roll2 = rand.nextInt(6) + 1; sum = roll1 + roll2; System.out.println(roll1 + " + " + roll2 + " = " + sum); tries++; } System.out.println("You won after " + tries + " tries."); } }