Tuesday, September 3, 2013

Java Codes





Java is a high-level programming language originally developed by Sun Microsystems and released in 1995.
Java runs on a variety of platforms, such as Windows, MacOS, and the various versions of UNIX.
Sun Micro systems has renamed the new J2 versions as JavaSE, JavaEE and JavaME respectively. Java is guaranteed to be.




Simple Java programme


public class Ex1000 {

      /**
       * @param args
       */
      public static void main(String[] args) {
            // TODO Auto-generated method stub
            double salary,allowensses,rate;
            salary=50000;
            if(salary<30000)
                  rate=0.1;
            else
                  rate=0.05;
            allowensses=salary*rate;
            System.out.println("Salary is"+" "+salary);
                        System.out.println("Alownessess is"+" " +allowensses );
      }

}

DO & While Java Codes



public class Ex1500 {

      /**
       * @param args
       */
      public static void main(String[] args) {
            // TODO Auto-generated method stub
            int i=1;
            do
            {
                  System.out.println(i);
                  i=i+1;
            }
            while(i<=5);
            {
System.out.print(i);
i=i+1;
            }
      }
           
}


For Condition in Java




public class Ex1500 {

      /**
       * @param args
       */
      public static void main(String[] args) {
            // TODO Auto-generated method stub
            for(int i=1;i<=5;i=i+1)
           
            {
                  System.out.println("Billionpc");
                 
            }
           
           

            }
      }
           

Java Switch & Case Programme



 public class Ex1500 {

      /**
       * @param args
       */
      public static void main(String[] args) {
            // TODO Auto-generated method stub
            int marks=90;
            int indicator=marks/10;
            String grade;
            switch(indicator)
            {
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            grade="Fail";
            break;
            case 5:
            case 6:
            grade="Pass";
            break;
            case 7:
            grade="Credit";
            break;
            default:
                  grade="Disticshion";
                 
           
            }
                  System.out.println(grade);
                 
           
      }
}

0 comments:

Post a Comment

Twitter Facebook

 
Design by Free Billionpc Themes | Bloggerized by Pubudu Thilan - Billion Pc Themes