public class Conversion {
  public static void main(String [] args) {
   int i1, i2;
   double d1, d2;
   //For integers, all of these are OK:
   i1 = 2;
   i2 = i1;
   i1 = -2*i2;
   i1 = i1/3; //Q: what is the result here?

   //These are NOT OK: why?
   //i1 = 2.0;
   //i1 = 3/2.0; 

   //==================================================================//
   //For doubles, all of these are OK:
   d1 = 2; //what gets stored in d1?   
   d2 = d1;
   d1 = 3/2; //result here?
   d1 = 3/2.0; //and here?

   //Simply casting to "int" truncates the result
   i1 = (int) (3/2.0); 
   
   //Math.round can be used to round up. 
   i1 = (int)Math.round(3/2.0); 
  }
}


/*
i1 = 2.0; //not OK  ==>  i1 = (int) 2.0; //OK, i1 gets the value 2.
i1 = 3/2.0; //not ok ==>  i1 = (int) (3/2.0); //OK, i1 gets "1".
i1 = (int)Math.round(3/2.0); //OK, i1 gets "2"
*/
