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...

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("\n\n"); } } 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; } }
Nov 17, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here