Question: Write a Java program that checks the 4 purchased tickets against the winning numbers. For that purpose, you need to do the following: Create a

Write a Java program that checks the 4 purchased tickets against the winning numbers. For that purpose, you need to do the following:

Create a method called "generateTicket" that includes the code provided (5 non-repeating random numbers) below and returns a single dimension array of type integer.

Create a single dimension array called "winningNumbers" for the winning numbers.

Create a two-dimensional array called "Tickets" to hold all 4 tickets' information.

Compare each ticket to the winning numbers and announce the winning as follows:

$100K if the ticket matches all 5 winning numbers.

$20K if the ticket matches 4 winning numbers.

$2K if the ticket matches 3 winning numbers.

int[] numbers = new int[5];

for (int i = 0; i < 5; i++)

int randomNum = new Random().nextint(10) + 1;

boolean unique = true;

for (int j = 0; j < i; i++) {

if (numberslil == randomNum) {

unique = false;

break;

}

}

if (unique) {

numbers[i] = randomNum;

}else {

i-;

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!