Even or Odd check in JAVA programming


//This program is about to check a given number is Even or Odd.....

package SolveProblem;//Your Package name.

import java.util.Scanner;

public class EvenOrOdd {

    public static void main(String[] args) {
        Scanner myScanner=new Scanner(System.in);  ///////Make your scanner
       
        int n;
       
        System.out.println("Enter a number to check it Even or Odd : ");
        n=myScanner.nextInt();
       
        if (n%2==0) {
            System.out.println("The number "+n+ "is Even");
        }else {
            System.out.println("The number "+n+ " is odd");
        }
    }

}

No comments:

Post a Comment