Tuesday, 27 February 2018

IF - Else Conditional Statement in Java (Check input Number is Even or Odd)









package javaapplication4;



import java.util.Scanner;





public class JavaApplication4 {



   

    public static void main(String[] args)

    {

        Scanner obj=new Scanner(System.in);

        int i;

        System.out.println("Enter the Number: ");

        i=obj.nextInt();

        if (i%2==0)

        {

            System.out.println(i+" is an even number");

        }

        else   

        {

            System.out.println(i+" is an Odd number");

        }

    }

   

}



No comments:

Post a Comment

Pass Dynamically Added Html Table Records List To Controller In Asp.net MVC

Controller Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ...