title: Finding larger number within a range
body: <p>I have kept at these CodingBat questions and I ran into another problem.</p>
  
  <p>The assignment was this:</p>
  
  <blockquote>
    <p>Given 2 positive int values, return the larger value that is in the range 10..20 inclusive, or return 0 if neither is in that range.</p>
  </blockquote>
  
  <p>Some Examples: </p>
  
  <ul>
  <li>max1020(11, 19) → 19</li>
  <li>max1020(19, 11) → 19</li>
  <li>max1020(11, 9) → 11</li>
  </ul>
  
  <p>My solution is:</p>
  
  <pre><code>public int max1020(int a, int b) {
      if (((a &gt;= 10 &amp;&amp; a &lt;= 20) || (b &gt;= 10 &amp;&amp; b &lt;= 20)) &amp;&amp; a &gt;= b) {
          return a;
      }
  
      if (((a &gt;= 10 &amp;&amp; a &lt;= 20) || (b &gt;= 10 &amp;&amp; b &lt;= 20)) &amp;&amp; b &gt;= a) {
          return b;
      } else {
          return 0;
      }
  }
  </code></pre>
  
  <p>The code returned the correct output more than half of the time, but it did not work as expected in certain scenarios. The scenarios are when the input was (10,21),(21,10),(23,10).</p>
  
  <p>This is weird because I explicitly excluded #>20 yet it returns 21, 21, and 23 respectively for the above three scenarios.</p>
  
  <p>Where did I make a mistake?</p>