Question: need a java structure chart for my below java program import java.util.Scanner; public class Problem_6_22 { public static void main(String[] args) { boolean run =

need a java structure chart for my below java program

import java.util.Scanner;

public class Problem_6_22 { public static void main(String[] args) { boolean run = true; while(run) { //Creates a Scanner to take in user input Scanner input = new Scanner(System.in);

//Prompts the user to enter an integer System.out.printf("Enter a number: "); long number = input.nextLong();

//Displays the square root System.out.printf("The approximated square root of " + number + " is: " + sqrt(number)); System.out.printf(" "); } }

public static double sqrt(long n) { //makes the initial guess to positive value long lastGuess = 1; long nextGuess = (lastGuess + n / lastGuess) / 2;

//If the difference between nextGuess and lastGuess is less than 0.0001, //it returns nextGuess as the approximated square root of n. while (nextGuess - lastGuess > 0.0001) { lastGuess = nextGuess; nextGuess = (lastGuess + n / lastGuess) / 2; } lastGuess = nextGuess; return nextGuess = (lastGuess + n / lastGuess) / 2; } }

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!