Write a Lottery class that simulates a lottery.  The class should have an array of  seven integers named lotteryNumbers.  The constructor should use the Random class (from the Java API) to generate a random number in the range 0 through 14 for each element in the array.  The class should also have a method that accepts an array of seven integers that represent a person'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 three matching digits (elements 3 and 5).

 

lotteryNumbers array

 

9

12

13

7

5

9

8

 

user's array

 

6

2

6

7

14

9

5

 

In addition, the class should have a method that returns a copy of the lotteryNumbers array.

 

Your program should ask the user to enter five numbers. 

Your 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.

 

Your program should have the usual javadocs information; echo the input as usual; include inline comments; and have good indentation with no lines that wraparound when printing

 

 

This lab is taken from Starting Out with Java 5 by Tony Gaddis (page 545, #9).  It has been modified slightly by Elizabeth Adams