In a Java program, you are developing a method used to determine whether a given number is even or odd. Currently, the program isn't working as intended. Your task is to fill the blanks in code to correctly declare the main method, state return type for the findEvenOrOdd method and ensure appropriate value is returned based on the if-else branching logic.
Declaring methods
Fixing the 'findEvenOrOdd' method logic
Report a typo
Fill in the gaps with the relevant elements
public class Main {
public void (String[] args) {
String result = findEvenOrOdd(5);
System.out.println(result);
}
static String findEvenOrOdd(int num) {
if (num % 2 == 0) {
"Even";
} else {
return "Odd";
}
}
} ___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.