Tuesday, April 9, 2013

Selenium : Basic arithematic operations and Insert Spaces

Basic arithematic operations



//To demonstrate the use of all arithematic operators
//Inserts 2 spaces   -     String.format("%2s","")

public class All_Arithematic_Operators
{

 public static void main(String[] args)
 {
  System.out.println(1+2);
  System.out.println(1-2);
  System.out.println(1/2);
  System.out.println(1*2);
  System.out.println(Math.sqrt(2));

  int a=1,b=2;
  if (a==1 && b==2 )
  {
   System.out.println("a==1 && b==2"+String.format("%2s","")+"true --a="+a+" b="+b);//Insert spaces
  }
  if (a!=2 || b!=1 )
  {
   System.out.println("a!=2 || b!=1"+String.format("%2s","")+"true --a="+a+" b="+b);//Insert Spaces
  }

  if (a < b)
  {
   System.out.println("a < b"+String.format("%2s","")+"true --a="+a+" b="+b);//Insert Spaces
  }
  if (a <= b)
  {
   System.out.println("a <= b"+String.format("%2s","")+"true --a="+a+" b="+b);//Insert Spaces
  }

 }

}

No comments:

Post a Comment