// Zorah Fung, CSE 142 // Simulates dice rolls. Rolls a pair of dice until the sum of the two is seven // and reports the total number of rolls. import java.util.*; public class Dice { public static void main(String[] args) { int sum = -1; int tries = 0; Random r = new Random(); while (sum != 7) { int die1 = r.nextInt(6) + 1; int die2 = r.nextInt(6) + 1; sum = die1 + die2; System.out.println(die1 + " + " + die2 + " = " + sum); tries++; } System.out.println("You won after " + tries + " tries!"); } }