Assignment: Module 03- Part 02
Input:
Enter the no. 4
Output:
The given no is even
Input:
Enter the no. 3
Output:
The given no is odd
Here is the Java code for the class OddExample:
import java.util.Scanner;
public class OddExample {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter the no.: ");
int num = sc.nextInt();
if (num % 2 == 0) {
System.out.println("The given no is even");
} else {
System.out.println("The given no is odd");
}
}
}
Output
Enter the no.: 4
The given no is even
Enter the no.: 3
The given no is odd