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!!!!");
}
}
g89 0 Newbie Poster
g89 0 Newbie Poster
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
Neel_4 0 Newbie Poster
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.