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");

        }

    }

   

}



How to get user input in java programming PART-3







package javaapplication3;



import java.util.Scanner;









public class JavaApplication3

{



 

    public static void main(String[] args)

    {

       byte b=127;

    System.out.println("value of byte variable is "+b);

    short s=32767;

    System.out.println("value of short variable is "+s);

    long l=659685085;

    System.out.println("value of long variable is "+l);

    int i=654654;

    System.out.println("value of int variable is "+i);

    float f=5.323232f;

    System.out.println("value of float variable is "+f);

    double d=543545435.43;

    System.out.println("value of double variable is "+d);

    char c='a';

    System.out.println("value of char variable is "+c);

    boolean bo=true;

    System.out.println("value of boolean variable is "+bo);

   

        System.out.println("------------------------------------------------");

     

        Scanner obj=new Scanner(System.in);

        b=obj.nextByte();

    System.out.println("value of byte variable is "+b);

 

        s=obj.nextShort();

            System.out.println("value of short variable is "+s);

        l=obj.nextLong();

          System.out.println("value of long variable is "+l);

        i=obj.nextInt();

            System.out.println("value of int variable is "+i);

        f=obj.nextFloat();

         System.out.println("value of float variable is "+f);

        d=obj.nextDouble();

            System.out.println("value of double variable is "+d);

        c=obj.next().charAt(0);

         System.out.println("value of char variable is "+c);

       

       

       

   

    }

   

}



Premitive Data types in java









package javaapplication3;



import java.util.Scanner;





public class JavaApplication3

{



 

    public static void main(String[] args)

    {

       byte b=127;

    System.out.println("value of byte variable is "+b);

    short s=32767;

    System.out.println("value of short variable is "+s);

    long l=659685085;

    System.out.println("value of long variable is "+l);

    int i=654654;

    System.out.println("value of int variable is "+i);

    float f=5.323232f;

    System.out.println("value of float variable is "+f);

    double d=543545435.43;

    System.out.println("value of double variable is "+d);

    char c='a';

    System.out.println("value of char variable is "+c);

    boolean bo=true;

    System.out.println("value of boolean variable is "+bo);

   

   

    }

   

}


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 ...