package rebelsky.sqrt; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigDecimal; public class TestRoot2 { public static void main(String[] args) throws Exception { PrintWriter pencil = new PrintWriter(System.out, true); BufferedReader eyes = new BufferedReader(new InputStreamReader(System.in)); BigDecimal number = IO.readBigDecimal(pencil, eyes, "Find the square root of: "); BigDecimal epsilon = IO.readBigDecimal(pencil, eyes, "Within this approximation: "); BigDecimal root = MyMath2.sqrt(number, epsilon); pencil.println("The square root of " + number + " is approximately " + root.setScale(epsilon.scale()+1, BigDecimal.ROUND_HALF_UP)); } }