Question: CODE IN JAVA Develop a program named Lottery (name of the Java class) that simulates a lottery. In this lottery, 5 integers are randomly drawn

CODE IN JAVA

Develop a program named Lottery (name of the Java class) that simulates a lottery. In this lottery, 5 integers are randomly drawn from the possible integers 1 to 69. Use an array to simulate the selection of winning numbers and ensure that the 5 selected numbers are unique. Store these winning numbers in an array and display the numbers in ascending order.

Users have a lottery ticket with 5 unique numbers from 1 to 69. A ticket is a winning ticket if there are 4 or more matches between the numbers in users ticket and the winning numbers.

Include a method called checkTicket that accepts the array of winning numbers as argument, prompts the user for their ticket numbers (assume that the user will enter 5 valid, unique numbers), and returns the number of matches.

Based on the number of matches, inform the user if they have a winning ticket.

Sample 1:

Winning numbers: 15 27 34 48 63

Enter your ticket numbers: 15 25 45 53 61 [enter]

Sorry. Good luck!

Sample execution 2: Winning numbers: 15 27 34 48 63

Enter your ticket numbers: 15 27 35 48 63 [enter]

Congratulations. You are the winner!

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!