title: Random number guessing game with if statement and a for loop Java
body: <p>My name is Fermin.  I'm new in this forum and I'm also studying Java to be a Java developer.  I'm stuck on an assignment and I would like some help from anyone.  Here is the description and the  code 
  Using an if statement in the for block, determine
  whether randNum and guessNum are equal.</p>
  
  <pre><code>public class GuessGame {
  
  /**
   * @param args the command line arguments
   */
  public static void main(String[] args) {
  
  
       int randNum , guessNum ;
       //Generates a random number from 1 to 10
       randNum = new java.util.Random().nextInt(10) + 1;
       System.out.println("Im thinking of a number from 1 to 10");
  
    for (guessNum = 0; guessNum &lt;= 10; guessNum ++){
  
        java.util.Scanner scan = new java.util.Scanner(System.in);
        guessNum = scan.nextInt();
  
        if (guessNum == randNum) {
             System.out.println("you guess" + guessNum );
      }
    } 
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>Updated code</strong></p>
  
  <pre><code> import java.util.Random;
   import java.util.Scanner;
  
   public class NumberGuess {
  
      public static void main(String[] args) {
  
          Scanner scan = new Scanner(System.in);
          Random rand = new Random();
  
          System.out.println("Im thinking of a number from 1 to 10");
          int number = scan.nextInt(10);
           //Generates a random number from 1 to 10
          int number2 = rand.nextInt(10)+1;
          System.out.println("you enter the number" + " " + number);
  
  
          for (int counter = -1; counter &lt; 3; counter ++ ){
               if(number!= number2)
                 System.out.println("and your random number is:" + " " + number2 + " " + "please try again"); 
               else 
                   System.out.println("your guess number is equal to the random number Good job guessing");
  
               break;
           }
  
      }
    } 
  </code></pre>