Answer:
public static boolean isOdd(int n1){
if (n1%2==0){
System.out.println("The number is even");
return true;
}
else{
System.out.println("The number is odd");
return false;
}
}
Step-by-step explanation:
Using Java program language;
Declare the method fix the return type to be boolean
use the modulo operator (%) to check if even since (n%evenNo is equal to 0)
return true is even or false if not
See a complete program with user prompt using the scanner class below
import java.util.Scanner;
public class TestClock {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter any Integer Number");
int n = in.nextInt();
isOdd(n);
}
public static boolean isOdd(int n1){
if (n1%2==0){
System.out.println("The number is even");
return true;
}
else{
System.out.println("The number is odd");
return false;
}
}
}