//  Data Structures with Java by John R. Hubbard
//  Copyright McGraw-Hill, 2001
//  Problem 1.6 on page 21


public class Testing
{ public static void main(String[] args)
  { double x = 1.23456;
    while (x<1e10)
    { System.out.println("round(" + x + ",2) = " + round(x,2));
      x *= 2;
    }
  }
  
  public static double round(double x, int precision)
  { double pow10 = Math.pow(10,precision);
    return Math.round(x*pow10)/pow10;
  }
}
