Saturday, 23 August 2014

Odd or Even

package com.tutorial4u;

import java.util.Scanner;

public class OddorEven {
       public static void main(String[] args) {
             System.out.println("Enter an Integer to check if it is odd or even.");
             Scanner sc = new Scanner(System.in);
             int num = sc.nextInt();
             if(num%2==0){
                    System.out.println("Entered number is even. ");
             }else{
                    System.out.println("Entered number is odd. ");
             }
       }

}


Output : 

Enter an Integer to check if it is odd or even.
24
Entered number is even.

No comments:

Post a Comment

No of Occurrence in Array

package com.tutorial4u; import java.util.HashMap; /************************************************************  No of Occurrence in Array...