Write a Java program that displays a table of square roots and cube roots. Use a loop to print the roots of numbers from 0 to 100, in increments of 5, as shown below. Output formatted columns with the number of decimal places as shown.
roots table
1
Expert's answer
2016-02-22T02:38:31-0500
public class Main {
public static void main(String[] args) {
System.out.println("square root cube root");
for (int i = 0; i < 101; i+=5) { System.out.printf("%03d = %07.4f %03d = %07.4f%n",i, Math.sqrt(i), i, Math.cbrt(i)); }
Comments
Leave a comment