Odd OR Even Program in Java

Table of Contents

Odd OR Even Program in Java

Compile and Run the following code with Command-Prompt Or download Notepad++.

For Compilation javac Sample.java

For Execution java Sample

import java.util.Scanner;
class Sample
  public static void main(String[] args)
    int a;
    Scanner sc = new Scanner(System.in);
    System.out.println("Enter the number: ");
    a = sc.nextInt();
    if(a%2 == 0)
      System.out.println("The given number is even");
      System.out.println("The given number is odd");

Next Largest among all in Java

Leave a Reply