So the prelab for my CSE class asks
Your assignment in version 1 is to write a Java program that lets you select six
lottery numbers. For this version, you can accept any six values including
duplicates. Your program must have the following elements:
- Create a class named Lottery1
- Use a loop to continue prompting for the six integers. Exit when all six values
have been captured.
- Use an array to store the six int values.
- After populating the array, use a loop to print out each of the values.
- Perform everything within the main method.
With output of
SAMPLE OUTPUT Version 1:
>java Lottery1
Enter a number from 1-54 (pick #1): 12
Enter a number from 1-54 (pick #2): 60
Enter a number from 1-54 (pick #3): 12
Enter a number from 1-54 (pick #4): 26
Enter a number from 1-54 (pick #5): 15
Enter a number from 1-54 (pick #6): 9
Playing the following six numbers:
12 60 12 26 15 9
So far I have
import java.util.Scanner;
class Lottery1
{
static int x;
static int [] a;
public static void main(String [] args)
{
int i = 0;
while (i < 6)
{
i++;
System.out.print("Enter a number from 1-54 (pick #" + i + "): ");
Scanner input = new Scanner(System.in);
int x = input.nextInt();
int [] a = int[] x;
}
System.out.println();
System.out.println("Playing the folowing six numbers: ");
System.out.print(a[x]);
}
}
I need to fix my arrays so that what I input for each will print at the end. I've searched high and low to no avail... Please show me what my problem is!