title: Trying to calculate sum of odd numbers in given range (java) - bug in a code?
body: <p>I am taking an Udemy course, and I have a problem with a challenge. The author seems to be unwilling to give any advice, so I am asking here. </p>
  
  <p>THe challenge is to create a code using for loop that will calculate sum of odd numbers in any given range (range is defined by 'start' and 'end' parameters). First method (isOdd) checks if the number is odd, the second calculates the sum.</p>
  
  <p>InteliJ gives me now warnings or errors, but when testing, the code is not displaying correct results. I have no idea where the bug is. Can anybody help?</p>
  
  <pre><code>public class SumOddRange {
    public static boolean isOdd(int number) {
          if (number &lt; 0) {
              return false;
          } else if (number % 2 &gt; 0) {
              return true;
          } else {
              return false;
          }
  
      }
  
     public static int sumOdd (int start, int end) {
          int sum = 0;
          for (int i = start; i &lt;= end; i++) {
  
              if (isOdd(i) &amp;&amp; end &gt;= start &amp;&amp; start &gt; 0) {
                  sum += i;
                  return sum;
              }
          }
          return -1;
     }
  }
  </code></pre>