It is very basic program to start with programming.You might be knowing that even numbers are those numbers which are divisible by 2 and odd numbers are those which are not.
Enjoy Reading.
So lets see implementation in the example given below:
import java.util.Scanner;
/**
*
*/
/**
* @author Dixit
*
*/
public class EvenOddExample {
/**
* @param args
*/
public static void main(String[] args) {
int x;
System.out.println("Enter number to check if it is odd or even ");
Scanner in = new Scanner(System.in);
x = in.nextInt();
if ( x % 2 == 0 )
System.out.println("You entered an even number.");
else
System.out.println("You entered an odd number.");
}
}
Enjoy Reading.
No comments:
Post a Comment