title: Having An Issue With Randomly Generated Numbers - Java
body: <p>I am working on this project from the Java Programming book by Joyce Farrell, and I am having an issue with the Randomly Generated number and the user's guesses not being checked correctly. For example the user has 3 guesses, lets say their first guess it 2 and the first randomly generated number is 2 the program will print out You lose. When the guess is actually correct. Please help me. I have added the details of the program plus what I have done so far.</p>
  
  <hr>
  
  <p>Create a lottery game application. Generate three random numbers (see Appendix D for help in
  doing so), each between 0 and 9. Allow the user to guess three numbers. Compare each of the
  user's guesses to the three random numbers and display a message that includes the user's 
  guess, the randomly determined three-digit number, and the amount of money the user has 
  won as follows.</p>
  
  <h2>Matching Numbers                    Award($)</h2>
  
  <p>Any one matching                       10
  Two matching                             100
  Three matching, not in order       1000
  Three matching, in exact order    1,000,000</p>
  
  <h2>No match                                     0</h2>
  
  <p>Make certain that your application accommodates repeating digits. For example, if a user
  guesses 1, 2, and 3, and the randomly generated digits are 1, 1, and 1, do not give the user
  credit for three correct guesses - just one. Save the file as Lottery.</p>
  
  <hr>
  
  <p><strong>My Source Code</strong></p>
  
  <pre><code>// Filename: Lottery.java
  // Written by: Andy A
  // Written on: 14 January 2015
  
  import java.util.Scanner;
  import java.util.Random;
  
  public class Lottery {
  
      public static void main(String[] args) {
  
          Scanner userInput = new Scanner(System.in);
          Random ranNum = new Random();
  
          // LIMIT Contains The Numbers From 0 - 9
          // TIMES Contains The Number of Time ranNum Should Run
          final int LIMIT = 9;
          final int TIMES = 3;
  
          // Users Guesses
          int usersFirstGuess;
          int usersSecondGuess;
          int usersThirdGuess;
  
          // Randomly Generated Numbers
          final int GenFirst = ranNum.nextInt(LIMIT);
          final int GenSecond = ranNum.nextInt(LIMIT);
          final int GenThird = ranNum.nextInt(LIMIT);
  
          // User is asked for 3 guesses
          System.out.println("Please enter your first guess: ");
          usersFirstGuess = userInput.nextInt();
          System.out.println("Please enter your second guess: ");
          usersSecondGuess = userInput.nextInt();
          System.out.println("Please enter your third and final guess: ");
          usersThirdGuess = userInput.nextInt();
  
          // Winning Amounts
          final double WinTen = 10;
          final double WinHun = 100;
          final double WinThund = 1000;
          final double WinMillion = 1000000;
          final int WinZero = 0;
  
          // Shows the randomly generated numbers
          for(int x = 0; x &lt; TIMES; ++x)
              System.out.print(ranNum.nextInt(LIMIT) + " ");
          System.out.println();
  
          // First Generated
          if(GenFirst == usersFirstGuess ) {
              System.out.println("You have won: $" + WinTen);
          }
              else if(GenSecond == usersSecondGuess) {
                      System.out.println("You have won: $" + WinTen);
              }
              else if(GenThird == usersThirdGuess) {
                  System.out.println("You have won: $" + WinTen);
              }
      }
  }
  </code></pre>