title: Validating for Binary codes and repeating program without infinite loop
body: <p>I was assigned to make a program that converts Binary to decimal. I got that part done with no problems but I have to validate what the user inputs to make sure they put in binary or else it should say "try again" I also have to keep the program repeating using letter "y/Y" to continue or else it exists without using an infinite loop. I have no idea how to do it without an infinite loop. Thank you</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import java.util.Scanner;
  class Quiz4 {
      public static void main(String args[]){
         Scanner input = new Scanner( System.in );
         System.out.print("Enter a binary number: ");
         String binaryString =input.nextLine();
         System.out.println("Output: "+Integer.parseInt(binaryString,2));
      }
  }</code></pre>
  </div>
  </div>
  </p>