10/27/2020 Java Babylonian Algorithm. The Babylonian Algorith... | Chegg.
com
NEW!
Textbook Solutions Expert Q&A Study Pack Practice
Find solutions for your homework Search
home / study / engineering / computer science / computer science questions and answers / java babylonian algorithm. the babylonian algorithm to
t…c
com…
Question: Java Babylonian Algorithm. The Babylonian algorithm to comput Post a question
Answers from our experts for your tough
homework questions
See this question in the app
Enter question
Java
Babylonian Algorithm. The Babylonian algorithm to compute the square root of a positive number n is as
follows: Continue to post
1. Make a guess at the answer (you can pick n/2 as your initial guess).
20 questions remaining
2. Computer = n / guess.
3. Set guess = (guess +r) / 2
2.
4. Go back to step 2 until the last two guess values are within 1% of each other.
Write a program that inputs an integer for n, iterates through the Babylonian algorithm until the guess is
Snap a photo from your
within 1% of the previous guess, and outputs the answer as a double to two decimal places. Your answer
should be accurate even for large values of n. phone to post a question
We'll send you a one-time download
INPUT and PROMPTS. The program prints "This program estimates square roots." and then prompts for a link
positive integer as follows: ("Enter an integer to estimate the square root of: " and then reads in the integer.
OUTPUT. Each time a new guess is computed, the program prints the line "Current guess: g", where g is
the current guess, printed out with no special formatting. The nal output is "The estimated square root of 888-888-8888 Text me
x is y", where x is the integer that was read in and y is the value computed by the procedure described
above, printed out to two decimal places and a total of six characters. By providing your phone number, you agree to receive a one-time
automated text message with a link to get the app. Standard
messaging rates may apply.
CLASS NAMES. Your program class should be called Babylonia
What I have so for:
import [Link];
public class Babylonia My Textbook Solutions
{
public static void main(String[] args)
{
int n;
double guess;
Laboratory... Electronic... Signals and...
double r;
9th Edition 11th Edition 2nd Edition
[Link] Algorithm.-,… 1/6
10/27/2020 Java Babylonian Algorithm. The Babylonian Algorith... | [Link]
Scanner input = new Scanner([Link]); View all solutions
NEW!
[Link]("This Textbooksquare
program estimates Solutions
roots."); Expert Q&A Study Pack Practice
[Link]("Enter an integer to estimate the square root of: ");
n = [Link](); Computer Science Chegg
[Link](); tutors who can help right
guess = n / 2.0; now
r = 0;
do Aditya A.
767
NIT Bhopal
{
if(guess != 0)
Bishrut J.
110
r = n / guess; BE Engineering
guess = (guess + r) / 2;
[Link]("Current guess: " + guess); Rashi A.
213
[Link] university
}
while((r - guess > 0.01) || (guess - r > 0.01));
[Link]("The estimated square root of %d is %4.2f", n, guess);
Find me a tutor
}
}
Expected Output:
This program estimates square roots.
Enter an integer to estimate the square root of:
Current guess: 1.5
The estimated square root of 2 is 1.50
Actual Output:
This program estimates square roots.
Enter an integer to estimate the square root of:
Current guess: 1.5
Current guess: 1.4166666666666665
Current guess: 1.4142156862745097
The estimated square root of 2 is 1.41
Expert Answer
Friend answered this
Was this answer helpful? 1 0
9,648 answers
Here is the updated code, refer the screenshot for the output
[Link] Algorithm.-,… 2/6
10/27/2020 Java Babylonian Algorithm. The Babylonian Algorith... | [Link]
--------------------------------------------------------------------------------------------------------------------------
----------------------- NEW!
Textbook Solutions Expert Q&A Study Pack Practice
import [Link];
public class Babylonia {
public static void main(String[] args) {
int n;
double guess;
double r;
Scanner input = new Scanner([Link]);
[Link]("This program estimates square roots.");
[Link]("Enter an integer to estimate the square root of: ");
n = [Link]();
[Link]();
guess = n / 2.0;
r = 0;
double last_guess = guess;
do {
r = n / guess;
guess = (guess + r) / 2;
last_guess = guess;
[Link]("Current guess: " + guess);
}
while (((guess - last_guess) / last_guess) > 0.01);
[Link]("The estimated square root of %d is %4.2f", n, guess);
--------------------------------------------------------------------------------------------------------------------------
-------------------------------
[Link] Algorithm.-,… 3/6
10/27/2020 Java Babylonian Algorithm. The Babylonian Algorith... | [Link]
NEW!
Textbook Solutions Expert Q&A Study Pack Practice
thank you !
Comment
Practice with similar questions
Q: The Babylonian algorithm to compute the square root of a positive number n is as follows: 1. Make a guess at the
answer (you can pick n/2 as your initial guess). 2. Computer = n / guess. 3. Set guess = (guess +r) / 2. 4. Go
back to step 2 until the last two...
A: See answer
[Link] Algorithm.-,… 4/6
10/27/2020 Java Babylonian Algorithm. The Babylonian Algorith... | [Link]
NEW!
Textbook Solutions Expert Q&A Study Pack Practice
Up next for you in Computer Science
In cryptarithmetic Problem 2. The game of
puzzles, Pig
mathematical equations is a simple two-player
are dice
writtenusing [Link] game in which the rst See more questions
letter can be a digit from player to reach 100 or for subjects you study
0 to more
9, but no two letters can points wins. Players take
See answer See answer
Questions viewed by other students
Q: Chapter 3 Exercise 1 Babylonian Algorithm. The Babylonian algorithm to compute the square root of a positive
number n is as follows: 1. Make a guess at the answer (you can pick n/2 as your initial guess). 2. Computer = n /
guess. 3. Set guess = (guess +r) / 2. 4. Go back to step 2 until the last two guess values are within 1% of each other.
Write a program that inputs an integer for...
A: See answer
Q: MYPROGRAMMINGLAB ASSIGNMENT. JAVA LANGUAGE
A: See answer
Show more
COMPANY
[Link] Algorithm.-,… 5/6
10/27/2020 Java Babylonian Algorithm. The Babylonian Algorith... | [Link]
LEGAL & POLICIES
NEW!
Textbook Solutions Expert Q&A Study Pack Practice
CHEGG PRODUCTS AND SERVICES
CHEGG NETWORK
CUSTOMER SERVICE
© 2003-2020 Chegg Inc. All rights reserved.
[Link] Algorithm.-,… 6/6