title: Guess random number, stops when random and guess are same
body: <pre><code>import java.util.*;
  /*
  10,100,1000  intervals of 10
  App generates a number:unkown
  person enters a number
  
  
  Miguel Castaneda
  */
  
  class GenerateNumber{
  
  public static void main(String args[])
  throws java.io.IOException {
  
  int num;
  
  /*
  loopTimes =  System.in.read(); //casted
  System.out.println("Loop Times is: " +loopTimes)
  */ //one byte at a time gets read
  
  
  System.out.println("How many times do you want to loop?");
  Scanner sc = new Scanner(System.in);
  int loopTimes = sc.nextInt();       //new scanner
  
  System.out.println("Loop Times is: " +loopTimes);
  
  
  System.out.println("What would be the max number to guess?");
  //genearte random number named :randomNumber
  
  int maxNumber = sc.nextInt();       
  Random generator = new Random();
  int i = generator.nextInt(maxNumber);
  
  
  int guess = generator.nextInt(maxNumber);
  System.out.println("Random number is: " + i); 
  System.out.println("Guess number is: " + guess); 
  
     while(i!=guess){
  if(guess==i)
  System.out.println("Guess and Random are same"); 
  
  guess = generator.nextInt(maxNumber);//guess until random and guess are same
  System.out.println("Guess number is: " + guess); //print out everytime guess and random arent the same
  counter++;
  }
  
  
  
  //loopTimes =  System.in.read(); //casted
  
  //if(num==rand)System.out.println("Right");
  //else System.out.println("Wrong");
  
  }}
  </code></pre>
  
  <p>How many times do you want to loop?
  10
  Loop Times is: 10
  What would be the max number to guess?
  10
  Random number is: 0
  Guess number is: 2
  Guess number is: 4
  Guess number is: 5
  Guess number is: 6
  Guess number is: 0</p>
  
  <p>----jGRASP wedge2: exit code for process is 0.
   ----jGRASP: operation complete.
  I want the computer to keep randomizing the number until random and guess are same I don't want to keep entering numbers.
  The code never shows that "Guess and random are same" line instead it just keeps randomizing the guess and leaves random same. How do I change this? </p>