title: While infinite (Restriction) loop is not working properly
body: <p>as one of my first java projects, I want to build a mortgage calc.
  I was trying to restrict the duration that the user can pick using this code</p>
  
  <pre><code>Scanner numOfPayments = new Scanner(System.in);
  while (true) {
      System.out.print("Enter number of payments (the number of Years you will be paying the loan):");
      short numOfPayments2 = numOfPayments.nextShort();
      if (numOfPayments2 &gt;= 1 &amp;&amp; numOfPayments3 &lt;= 30) {
          numOfPayments3 = (short) (numOfPayments2 * 12);
          break;
      }
      System.out.println("Enter a valid number of years(Between 1 and 30)");
  }
  </code></pre>
  
  <p>It worked with restricting other values, but not for this one.
  Thanks in advance</p>