Cycle 01
Lab Cycle 1 — Java Basics
Check Even or Odd
Problem Statement
Write a Java program to check if a number is even or odd.
import java.util.Scanner;
public class EvenOdd {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
if (num % 2 == 0)
System.out.println(num + " is Even");
else
System.out.println(num + " is Odd");
}
}
Question 3 of 5