Question: JAVA: FOR LOOPS: Complete the following program to make a table of integers and their square roots . The table should be formatted like this:

JAVA: FOR LOOPS: Complete the following program to make a table of integers and their square roots . The table should be formatted like this:

 n | Root of n ----|---------- 0 | 0.000000 1 | 1.000000 2 | 1.414214 ... 

The code supplied is:

import java.util.Scanner;

public class Roots { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter a positive integer: "); int n = in.nextInt(); System.out.println(" n | Root of n"); System.out.println("----|----------");

for (. . .) { . . . } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!