import java.util.Scanner;
import java.util.Random;

class Lottery
{   
    // MISSING CODE 
}

public class LotteryDemo
{
   public static void main(String[] args)
   {
      int[] userPicks = new int[5];
      int matching;

       // Create a Scanner object for keyboard input.
      Scanner keyboard = new Scanner(System.in);

      // Create a Lottery object.
      Lottery lotto = new Lottery();

      // Get the user's picks.
      for (int digit = 1; digit <= 5; digit++)
      {
         System.out.print("Enter digit " + digit + ": ");
         userPicks[digit-1] = keyboard.nextInt();
         while (userPicks[digit-1] < 0 || userPicks[digit-1] > 9)
         {
            System.out.print("ERROR. Enter a single digit (0 - 9): ");
            userPicks[digit-1] = keyboard.nextInt();
         }
      }

      // Compare.
      matching = lotto.numMatching(userPicks);

      // Display the results.
      int[] lottoNums = lotto.copy();
      System.out.print("Lottery numbers: ");
      for (int i = 0; i < lottoNums.length; i++)
         System.out.print(lottoNums[i] + " ");
      System.out.println();

      System.out.println("Number of matching digits: " +
                         matching);
      if (matching == 5)
         System.out.println("GRAND PRIZE WINNER!!!!");
   }
}

Write a Lottery class that simulates a lottery. The class should have an array of five integers named lotteryNumbers. The constructor should generate a random number in the range of 0 through 9 for each element in the array. Refer to Chapter 4's discussion of the Random class for generating random numbers. The class should also have a method that accepts an array of five integers that represents 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. Note that unline the Florida Lotto, the digits must match by position!

So post your code and actually ask a question. This isn't a homework completion service and no one is going to write detailed instructions on how to complete this.

Hey. Were you able to finish this code??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.