title: Wiring a while loop with a continue option in java
body: <p>I am working on a loan calculator with data validation.  I have written everything and good to go.  The only thing I cannot figure out is how to write a while loop in where the user is asked "Continue y/n?: " and then have the program continue ONLY when the user types y/Y and the program ENDS ONLY when the user types n/N, any other input should give an error message like "Invalid, you can only enter Y or N".  So if the user enters "x" it should display the error message.</p>
  
  <p>I have tried else if clauses, I have also tried to validate data with the methods I used in the rest of the program but I simply don't know how to validate strings. I can only do it with primitive data types.</p>
  
  <p>This is the only way i know how to write the loop as of now, the problem is it will simply end the program with anything but a Y.</p>
  
  <p>an option for the assignment is to use JOptionPane but I do not know how to incorporate that into the while loop and have it display a yes and a no button.</p>
  
  <pre><code>    String choice = "y";
  
      while (choice.equalsIgnoreCase("y")) {
  
      // code here
  
      System.out.print("Continue? (y/n): ");
          choice = sc.next();
      }
     }
  </code></pre>