Check that a String entered contains only 1's and 0's
<p>I am writing a program that switches a binary number into a decimal number and am only a novice programmer. I am stuck trying to determine that the string that was entered is a binary number, meaning it contains only 1's and 0's. My code so far is:</p>

<pre><code>  String num;
  char n;

  Scanner in = new Scanner(System.in);
  System.out.println("Please enter a binary number or enter 'quit' to quit: ");
  num = in.nextLine();
  n = num.charAt(0);
  if (num.equals("quit")){
    System.out.println("You chose to exit the program.");
    return;
  }

  if (n != 1 || n != 0){
    System.out.println("You did not enter a binary number.");
  }
</code></pre>

<p>As is, no matter what is entered (other then quit) the program out-puts "You did not enter a binary number" even when a binary number is inputted. I am sure my if statement is false or my character declaration is wrong, however I have tried everything I personally know to correct the issue and nothing I find online helps. Any help would be appreciated.</p>
