Privacy Policy Terms Of Use. Copyright © 2006-2010 Java Tutorials and Examples.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
- /*
- * Write a program to determine if number is even or odd. Program should take
- * the number from command line argument.
- *
- */
- import java.io.*;
- public class OddEvenNumbers
- {
- public static void main(String[] s)
- {
- int n=0;
- DataInputStream d1 = new DataInputStream(System.in);
- try{
- System.out.print("Enter A number: ");
- n = Integer.parseInt(d1.readLine());
- }catch(Exception e){
- System.out.println("Error Occured during IO");
- }
- if(n%2 == 0)
- System.out.println(n + " is Even Number");
- else
- System.out.println(n + " is Odd Number");
- }
- }

Post new comment