private double round(double value,int places){
  if (places < 0)   throw new IllegalArgumentException();
  long factor=(long)Math.pow(10,places);
  value=value * factor;
  long tmp=Math.round(value);
  return (double)tmp / factor;
}

private double round ( double value , int places ) { if ( places < 0 ) throw new IllegalArgumentException ( ) ; long factor = ( long ) Math . pow ( 10 , places ) ; value = value * factor ; long tmp = Math . round ( value ) ; return ( double ) tmp / factor ; }
method to round doubles at given places .
