Answer to Question #57965 in Java | JSP | JSF for Kenya

Question #57965
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));
}

}

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS