 <p>Given your requirements, this block looks wrong to me:</p> <pre><code>if(array[i] % 2 !=0 &amp;&amp; array[i] % 5 ==0){ odd++; } </code></pre> <p>You're incrementing a counter, but you're not creating a sum of odd numbers. Nor are you printing it. Try this:</p> <pre><code>int total = 0; if ( array[i] % 2 != 0 &amp;&amp; array[i] % 5 != 0) { // it's an odd number total += array[i]; } System.out.println("Total: " + total); </code></pre>