title: Java Basic High:Low Guessing Game Help (Loops)
body: <p>I stopped programming for a while now. Probably around 4 years, and I was just looking to mess around with it, so I decided to make a high:low number guessing game. (guess a number 1-100, program says if your guess is too high or too low) and I completely forgot how I would go about:</p>
  
  <p>a) Once the user guesses the correct number, asking if they want to play again
  b) If they don't guess the correct number (too high or too low), the program lets them guess again.</p>
  
  <p>I understand that you would need loops, but I just forgot about how I would go about them</p>
  
  <pre><code>package highlow;
  
  import java.util.Random;
  import java.util.Scanner;
  
  public class guessing {
      public static void main(String[] args){
  
          Scanner input = new Scanner(System.in);
  
          Random rand = new Random();
          int tries;
          int correctNum = rand.nextInt(100);
  
          System.out.println("enter a number 1-100");
          int guess1 = input.nextInt();
  
          if(guess1 &lt; correctNum){
              System.out.println("number is too low!");
          }
          else if(guess1 &gt; correctNum){
              System.out.println("Number is too high!");
          }
          else if(guess1 == correctNum){
              System.out.println("correct!");
          }
          else{
              System.out.println("not a valid option");
          }
  
  
      }
  
  }
  </code></pre>