SHARE
TWEET

Untitled

a guest Feb 14th, 2020 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static boolean isOdd(int number) {
  2.         if (number > 0) {
  3.             if (number % 2 != 0) {
  4.                 return true;
  5.             } else return false;
  6.         }
  7.         else return false;
  8.     }
  9.  
  10.  
  11.     public static int sumOdd(int start, int end) {
  12.         int sumOfOdds = 0;
  13.         if ((end > start) && (start > 0)) {
  14.             for (int i = start; i < end; i++) {
  15.                 if (isOdd(i)) {
  16.                     sumOfOdds +=i;
  17.                 }
  18.             }
  19.             return sumOfOdds;
  20.         }
  21.     return -1;
  22.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top