this is my first question on here so I'm not sure how everything works on StackOverflow. I know with an int you need to return something but for some reason, my code doesn't work. I tried all sorts of stuff to make this work but I have no clue anymore how I could solve this. Any help is greatly appreciated.
my code:
public class Main {
public static void main(String[] args) {
System.out.println(isOdd(10));
System.out.println(sumOdd(10, 50));
}
public static boolean isOdd(int number) {
if (number < 0) {
return false;
} else if (number % 2 == 0) {
return false;
} else {
return true;
}
}
static public int sumOdd(int start, int end) {
int sumOfOddNumbers = 0;
for (int i = 0; i >= 50; i++) {
if (isOdd(i) && end < 0 && start < 0 && end <= start) {
sumOfOddNumbers += i;
System.out.println("The sum of the odd numbers are " + sumOfOddNumbers);
} else {
return sumOfOddNumbers;
}
}
}