Absolute Java (6th Edition)
Absolute Java (6th Edition)
6th Edition
ISBN: 9780134041674
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 2, Problem 1PP

The Babylonian algorithm to compute the square root of a positive number « 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 for as many iterations as necessary. The more you repeat steps 2 and 3, the closer guess will become to the square root of n.

Write a program that inputs a double for n, iterates through the Babylonian algorithm five times, and outputs the answer as a double to two decimal places. Your answer will be most accurate for small values of n.

Blurred answer
Students have asked these similar questions
The Babylonian algorithm to compute the square root of a positive number n is asfollows:1. Make a guess at the answer (you can pick n/2 as your initial guess).2. Compute r = n / guess3. Set guess = (guess +r)/ 24. Go back to step 2 for as many iterations as necessary. The more you repeat steps2 and 3, the closer guess will become to the square root of n. Write a program that inputs a double for n, iterates through the Babylonian algo-rithm five times, and outputs the answer as a double to two decimal places. Your answer will be most accurate for small values of n.
Write an algorithm in pseudocode for the following problem:  Write a program that reads a series of daily high temperatures from the keyboard and then prints to the screen the number of days that each high was achieved.   Assume that the temperatures will fall between -40 and 110, inclusive.   You'll print the temperature and then the number of days for each temperature that was the high at least once.  So your output will be in two columns.  The key to this is that you'll have an array where the indices of the array represent the temperatures and the contents are the number of days where that temperature was the high.
Numeric Triangle Pattern Based on the example given on the previous module, create a program that replicated the triangle pattern shown. Try to look at the examples closely and think of an algorithm that replicates the outputs. Let's see if you still look at Triangle problems the same way after this problem. Input: Integer value n. Output: A triangle based on the inputted value of n.

Chapter 2 Solutions

Absolute Java (6th Edition)

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY