import java.util.*;

public class Examples { public static void main(String[] args) { int number; int pick; int chosen[] = new int[5]; int megaNumber = 46; // Range int lottoNumber; System.out.print("Lottery Numbers: "); // Randomly pick seven numbers from 1 to 56 for (int i = 0; i <=0; i ++) { //Create a Random Mega Number lottoNumber = (int) (megaNumber * Math.random()) + 1; for (pick = 0; pick < 5; pick ++) { //pick a random number number = (int) (56 * Math.random()) + 1; //check if the number is already been chosen for (int x = 0; x < 5; x++) { while (number == chosen[x]) { //pick a new number if it is already there number = (int) (56 * Math.random()) + 1; } } chosen[pick] = number;//Add the number to the array System.out.print(chosen[pick]+" "); } System.out.println("\n" + "The Mega Number is " + lottoNumber); } } }