Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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 through for each element in the array. The
class should also have a method that accepts an array of five integers that represent a persons 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 users array with sample numbers stored in each. There are
two matching digits elements and
lotteryNumbers array:
Users array:
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 digitsmatch, display a message proclaiming the user a grand prize winner The question should have two classes: Lottery and LotteryDemo.
Lottery class has an array of five integers named lotteryNumbers created by Random class.
LotteryDemo class has an array of five integers named userPicks entered by the user.e digits match, display a message proclaiming the user a grand prize winner.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started