Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2010 Barcelona Spain September 2010 Proceedings Part 3 Lnai 6323

Authors: Jose L. Balcazar ,Francesco Bonchi ,Aristides Gionis ,Michele Sebag

2010th Edition

3642159389, 978-3642159381

More Books

Students also viewed these Databases questions