title: What is the best way to repeat this loop?
body: <p>I'm new to this and new to loops. The slot machine code works fine. I want the below code to do the following:
  When asked <code>(Play again? (Y/N?))</code>, If I respond by saying <code>Y</code> the game restarts. If I respond by saying <code>N</code>, the program terminates. And finally, if I respond by pressing anything else e.g. <code>R</code>, the message repeats <code>(Play again? (Y/N?))</code>. I'm thinking a do loop, but not sure what elements go where. Thanks!</p>
  
  <pre><code>import java.util.Random;
  import java.util.Scanner;
  
  public class SlotMachine {
  public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      int slotOne;
      int slotTwo;
      int slotThree;
      String userResponse;
  
          Random randomNumbers = new Random();
  
          slotOne = randomNumbers.nextInt(10);  // Random number between 0 and 9
          slotTwo= randomNumbers.nextInt(10);  
          slotThree = randomNumbers.nextInt(10);  
  
  
          System.out.println(slotOne + " " + slotTwo +  " " + slotThree + " " );  // prints all three slot numbers next to each other
          if (slotOne != slotTwo &amp;&amp; slotOne != slotThree &amp;&amp; slotTwo != slotThree) // ! means does not equal
          { 
              System.out.println("No numbers match");  
          }
          else if (slotOne == slotTwo &amp;&amp; slotOne == slotThree) 
          { 
              System.out.println("All three match - jackpot"); 
          } 
          else
          { 
              System.out.println("Two numbers match"); 
          }       
  
          System.out.print("Play again? (Y/N?)");
          userResponse = scan.next();
  </code></pre>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>its the second loop that forces it to close?</p>