title: Java Lottery Array Program
body: <p>I am designing a program for my class that is supposed to simulate a lottery game. I am supposed to design a method that generates random lottery numbers, a method that asks and stores the user for their number choices, a method that compares the arrays to find how many numbers are the same, and then I am supposed to call them all back up to the main method, and create my output statement that contains some if statements that determine which prize is awarded for the particular amount of matches. </p>
  
  <p>Here is what I have thus far</p>
  
  <pre><code>import java.util.*;
  
  
  public class LotteryGame {
  /**
    The main method is the program's starting point 
  */
  public static void main(String[] args){
  
    int NUM_DIGITS = 5;
  
    int[] userDigits = new int[5];
    int[] lotteryNumbers = new int[5];
    int sameNum;
  
    generateNumbers(lotteryNumbers);
    getUserData(userDigits);
    compareArrays();
  
  
    System.out.println("Lottery numbers: " + lotteryNumbers[0] + " " +
    lotteryNumbers[1] + " " + lotteryNumbers[2] + " " + lotteryNumbers[3] +
    " " + lotteryNumbers[4] + " ");
  
    System.out.println("Player numbers:  " + userDigits[0] + " " + userDigits[1] + " " + userDigits[2] + " " + userDigits[3] + " " + userDigits[4] + " ");
    System.out.println("Number of matching digits: " + sameNum);
  
    if (sameNum == 5){
       System.out.println("GRAND PRIZE WINNER - $5 MILLION!!");
       }
  
    if (sameNum == 4){
       System.out.println("SUPER PRIZE WINNER - $500,000!!");
       }
  
    if (sameNum == 3){
       System.out.println("GOOD PRIZE WINNER - $5,000!!");
       }
  
    if (sameNum == 2){
       System.out.println("NICE PRIZE WINNER - $500!!");
       } 
  
    if (sameNum == 1){
       System.out.println("WINNER - $5!!");
    }
    if (sameNum ==0){
       System.out.println("No matching numbers - better luck next time");
       }
  
  
  } 
  public static int generateNumbers(int [] lotteryNumbers){
  
  
    Random randNum = new Random();
  
    lotteryNumbers[0] = randNum.nextInt(10);
    lotteryNumbers[1] = randNum.nextInt(10);
    lotteryNumbers[2] = randNum.nextInt(10);  
    lotteryNumbers[3] = randNum.nextInt(10);
    lotteryNumbers[4] = randNum.nextInt(10);
  
    return lotteryNumbers[4];
  }
  
  public static int getUserData (int [] userDigits){
    Scanner keyboard = new Scanner(System.in);
  
    System.out.print("Enter digit 1: ");
    userDigits[0] = keyboard.nextInt();
    System.out.print("Enter digit 2: ");
    userDigits[1] = keyboard.nextInt();
    System.out.print("Enter digit 3: ");
    userDigits[2] = keyboard.nextInt();
    System.out.print("Enter digit 4: ");
    userDigits[3] = keyboard.nextInt();
    System.out.print("Enter digit 5: ");
    userDigits[4] = keyboard.nextInt();
  
    return userDigits[4];
  
  }
  
  public static int compareArrays (int [] userDigits, 
                                      int [] lotteryNumbers){
  
   int sameNum = 0;
  
   for (int i = 0; i &lt; 5; i++){
  
       for (int x = 0; x &lt; 5; x++){
  
           if (lotteryNumbers[i] == userDigits[x]){
             sameNum++;
             }
                return sameNum;
                }                           
  
                return sameNum;                         
    }
                return sameNum;
  
   }
  
  }
  </code></pre>
  
  <p>I am very new to arrays (and Java at that) so my problems are in my return/call statements. Please excuse my spacey coding style and any blatant mistakes that I have made. Any tips,advice, solutions, or if you notice anything wrong with what I have please let me know. Thanks!</p>