Showing posts with label even odd without using if_else. Show all posts
Showing posts with label even odd without using if_else. Show all posts

Sunday, June 7, 2020

Write a program to input two numbers and check whether it is Even or Odd without using if else.

15)  Write a program in java to input two numbers and check whether it is Even or Odd     without using if else.

import java.util.*;
public class even_odd_without_ifelse
{
    public static void main(String args[ ])
    {
        Scanner sc = new Scanner (System.in);
        System.out.println("Enter a number");
        int a = sc.nextInt();
        String s = (a%2==0)?"EVEN":"ODD";
        System.out.println("Entered number is "+s);
    }
}

 jhvghvgk ;nkjn ,nkjhj