/* SquareRoot2.java CIS 160 David G. Klick 2015-09-11 Demonstrates getting a square root with Math.sqrt(). Same as SquareRoot.java, but uses printf() for formatting output. */ public class SquareRoot2 { public static void main(String[] args) { for (double x=1.0; x<21.0; x+=1.0) { System.out.printf("The square root of %02.0f is %6.4f\n", x, Math.sqrt(x)); } } } /* Sample output: The square root of 01 is 1.0000 The square root of 02 is 1.4142 The square root of 03 is 1.7321 The square root of 04 is 2.0000 The square root of 05 is 2.2361 The square root of 06 is 2.4495 The square root of 07 is 2.6458 The square root of 08 is 2.8284 The square root of 09 is 3.0000 The square root of 10 is 3.1623 The square root of 11 is 3.3166 The square root of 12 is 3.4641 The square root of 13 is 3.6056 The square root of 14 is 3.7417 The square root of 15 is 3.8730 The square root of 16 is 4.0000 The square root of 17 is 4.1231 The square root of 18 is 4.2426 The square root of 19 is 4.3589 The square root of 20 is 4.4721 */