// Yazzy Latif // 07-20-2020 // CSE142 // TA: Grace Hopper // A short program that generates random numbers in the range 0, 1, 2, ..., 10 until a 10 is // generated, at which point it reports that a 10 was generated and how many tries occurred before // they got a 10. import java.util.*; public class RandomWhile { public static void main(String[] args) { Random r = new Random(); int tries = 0; int num = -1; // prime the loop while (num != 10) { num = r.nextInt(11); // 0, 1, 2, .. 10 System.out.println("random number: " + num); tries++; } System.out.println("Found 10 after " + tries + " tries!"); } }