title: Using a method in the case section of a switch statement
body: <p>I am trying to use a switch statement in  my grading system and I have not found a proper  way to include a range of values in the switch case section. I however researched here and found the use of isBetween:</p>
  
  <pre><code>public static isBetween(int x, int lower, int upper)
  {
      return lower &lt;=x &amp;&amp; x&lt;=upper;
  }
  </code></pre>
  
  <p>I tried to use this in this manner to check if the mark submitted was between a range of 1-20:</p>
  
  <pre><code>switch (mark) {
      case isBetween(0, 20):
          System.out.println("Grade is E");
          break;
      case isBetween(21, 29):
          System.out.println("Grade is D");
          break;
  }
  </code></pre>
  
  <p>I know this is wrong since it does not work. Will somebody help correct my code? In this case I have to use a switch statement.</p>