I know something in my class is messed up. I'm just having a lot of trouble.
import java.util.Scanner;
import java.util.Random;
class Lottery
{
public int numMatching(int[] userPicks) {
return 0;
}
public int[] copy() {
return null;
}
}
public class WawrynovicLottery
{
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!!!!");
}
}

New Topic/Question
Reply
MultiQuote









|