10. Lottery Application Write a Lottery class that simulates a lottery. The class should have an array of five integers named lotteryNumbers. The constructor should use the Random class (from the Java API) to generate a random number in the range of 0 through 9 for each element in the array. The class should also have a method that accepts an array of five integers that represent a per- son's lottery picks. The method is to compare the corresponding elements in the two arrays and return the number of digits that match. For example, the following shows the lotteryNumbers array and the user's array with sample numbers stored in each. There are two matching digits (elements 2 and 4). lotteryNumbers array: User's array: 7 4 4 2 9 1 3 9 7 3 In addition, the class should have a method that returns a copy of the lotteryNumbers array. Demonstrate the class in a program that asks the user to enter five numbers. The program should display the number of digits that match the randomly generated lottery numbers. If all of the digits match, display a message proclaiming the user a grand prize winner.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 19RQ
icon
Related questions
Question
10. Lottery Application
Write a Lottery class that simulates a lottery. The class should have an array of five integers
named lotteryNumbers. The constructor should use the Random class (from the Java API) to
generate a random number in the range of 0 through 9 for each element in the array. The
class should also have a method that accepts an array of five integers that represent a per-
son's lottery picks. The method is to compare the corresponding elements in the two arrays
and return the number of digits that match. For example, the following shows the
lotteryNumbers array and the user's array with sample numbers stored in each. There are
two matching digits (elements 2 and 4).
lotteryNumbers array:
User's array:
7 4
4
2
1 3
7 3
In addition, the class should have a method that returns a copy of the lotteryNumbers array.
Demonstrate the class in a program that asks the user to enter five numbers. The program
should display the number of digits that match the randomly generated lottery numbers. If
all of the digits match, display a message proclaiming the user a grand prize winner.
Transcribed Image Text:10. Lottery Application Write a Lottery class that simulates a lottery. The class should have an array of five integers named lotteryNumbers. The constructor should use the Random class (from the Java API) to generate a random number in the range of 0 through 9 for each element in the array. The class should also have a method that accepts an array of five integers that represent a per- son's lottery picks. The method is to compare the corresponding elements in the two arrays and return the number of digits that match. For example, the following shows the lotteryNumbers array and the user's array with sample numbers stored in each. There are two matching digits (elements 2 and 4). lotteryNumbers array: User's array: 7 4 4 2 1 3 7 3 In addition, the class should have a method that returns a copy of the lotteryNumbers array. Demonstrate the class in a program that asks the user to enter five numbers. The program should display the number of digits that match the randomly generated lottery numbers. If all of the digits match, display a message proclaiming the user a grand prize winner.
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Program on Numbers
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT