Sunday, 5 November 2017

java program that check number is even or odd



Problem 09:
Write a program that check number is even or odd
Discripition:
If number mode 2 is zero number is positive other the number is negative.
Solution:
import java.util.*;
public class Message {
 public static void main(String[] args) {
  Scanner input= new Scanner(System.in);
   System.out.println("Enter five  number");
    int num=input.nextInt();
    if(num%2==0)
    System.out.println("The  number  "+num+" is even");
    else
        System.out.println("The  number  "+num+" is odd");
 }}
Output:
                         


No comments:

Post a Comment