title: How do I create a loop that will generate random numbers until it matches my user input?
body: <p>I'm very new at java. I'm doing an exercise and I am stuck. Basically I have to </p>
  
  <ol>
  <li>Ask the user to pick a random # from  1-100. Ask again if not between those #.</li>
  <li>Generate random # between 1-100 until it matches the user input. </li>
  <li>Print matching number and number of tries to get matching number.</li>
  </ol>
  
  <p>So far, I've done this:</p>
  
  <pre class="lang-java prettyprint-override"><code>import java.util.Scanner;
  import java.util.Random;
  
  public class RoughNums {
     public static void main(String[]args) {
        Scanner reader = new Scanner(System.in);
        Random rand = new Random();
        int rantInt = rand.nextInt(101);
  
        while(true) {
           System.out.println("Hello friend! Pick a number between 1 - 100: ");
           int pick = Integer.parseInt(reader.nextLine());
  
           if(pick &gt; 100) {
              System.out.println("Oops, number too big! Please try again!\n");
           } else {
              System.out.println("Let's see if I can get the same number too!");
           }
  
        }
  
     }
  }
  </code></pre>
  
  <p>I'm not sure where to go from here. Should I add another while loop? If so, how should I write it? How do I generate random numbers until it matches the user input number?</p>