public class ex4 { public static void main(String[] args) { double x = 2.0; double y = Math.sqrt(x); System.out.println("square root of " + x + " is " + y); System.out.printf("square root of %.1f is %.6f\n", x, y); } } Output: square root of 2.0 is 1.4142135623730951 square root of 2.0 is 1.414214