Showing posts with label even odd. Show all posts
Showing posts with label even odd. 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);
    }
}

Friday, June 5, 2020

Write a program in java to input a number and check whether it is Even or Odd?

9)  Write a program in java to input a number and check whether it is Even or Odd?

import java.util.*;
public class Even_Odd
{
    public static void main(String args[ ])
    {
        Scanner sc = new Scanner (System.in);
        System.out.println("Enter a numbers");
        int a = sc.nextInt();
        if(a%2==0)
        {
            System.out.println("Entered numbeer is even");
        }
        else
        {
            System.out.println("Entered numbeer is odd");
        }
    }
}

 jhvghvgk ;nkjn ,nkjhj