Babylonian algorithm

Assignment Help Data Structure & Algorithms
Reference no: EM13703792

Question: Babylonian Algorithm. The Babylonian algorithm to compute the square root of a positive number n is as given:

Step 1: Make a guess at the answer (you can pick n/2 as your initial guess).

Step 2: Computer = n / guess.

Step 3: Set guess = (guess +r) / 2.

Step 4: Go back to step 2 until the last two guess values are within 1% of each other.

Program: Write a program that inputs an integer for n, iterates through the Babylonian algorithm until the guess is 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. INPUT and PROMPTS. The program prints "This program estimates square roots." and then prompts for a 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 it he line "Current guess: g", where g is the current guess, printed out with no special formatting. The final output is "The estimated square root of 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 . CLASS NAMES. Your program class should be called Babylonia

The solution must be error free and compile correctly on first attempt.  Any code that does not do this will not be awarded points.

Reference no: EM13703792

Questions Cloud

Write a function named totamt : Write a function named totamt() that uses four parameters named quarters, dimes, nickels, and pennies, which represent the number of each of these coins in a piggybank.
Redesign the grading program as an object-oriented design : Redesign the grading program as an object-oriented design. We will start with a simple Student class. The student will have a name, an id (as a String) and a set of grades (as doubles).
What is the output of the statement : Given the subsequent array declaration, if the array is stored starting at address 2500, what is the output of the following statement?
Can firm increase variability of its product line : Can a firm increase the variability and diversity of its product line while simultaneous realizing the higher possible level of efficiency? Provide one product example for illustration.
Babylonian algorithm : Babylonian Algorithm. The Babylonian algorithm to compute the square root of a positive number n is as given:
Write a program that request a students name : Write a program that request a student's name in the subsequent form: lastName,firstName.
Determining the volume of the unit sphere : Write a C program for determining the volume of the unit sphere by the Monte Carlo Method      \(x^{2}+ y^{2} + z^{2} 0, y > 0, z > 0.\)    : This is what I have so far, but it's not working.
How will cyber security influence the next 10 years : How will cyber security influence the next 10 years?
Prepare a main function : Write a function that converts an input of some integer number of nickels into outputs of integer numbers of dollars, quarters, and nickels.

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Encryption feistel cipher and decryption algorithm

If this is psudocode for encryption feistel cipher determine decryption algorithm?Output: ciphertext = (left[16], right[16]) Explain pseudo-code of corresponding decryption algorithm for this cipher.

  Algorithm for a bank account

Write algorithm to settle following question: A bank account starts out with $10,000. Interest is compounded monthly at 6 percent per year (0.5 percent per month).

  Question about pure aloha

A group of N stations share a 56-kbps pure ALOHA channel. Every station outputs a 1000-bit frame on an average of once every one-hundred secs, even if the previous one has not yet been sent.

  What do you meant by an rfp

Select a specific category of vertical applications to investigate. Use the Internet and any other sources of information you might have to study some of the different products that are available in that category.

  Learning outcomes assesseda describe and discuss the

learning outcomes assesseda describe and discuss the issues involved in managing software selection. b compare

  Calculate the diffie-hellman key values

Calculate the Diffie-Hellman key values. Calculate values for both keys (secret key a and secret key b). You must show your work for full credit.This includes the calculations each person performs to calculate and verify the values.

  Design time randomized monte carlo algorithm

You have to design an O(n) time randomized Monte Carlo algorithm which computes an (1 + o)- approximate ham-sandwich cut with probability 1 - n-c for any given constant c > 0.

  Model of online music sharing

Since Napster is going out of business, you have decided to begin your own on line music sharing site. You will give individual music documents at your site.

  Calculate failure and success ratios using fifo page removal

Using FIFO page removal algorithm, do a page trace analysis indicating page faults with asterisks (*). Then calculate the failure and success ratios.

  Multiple choice - high school excel 2003

Cell E23 has a date value and you want to place that date on an invoice prefaced with the text located in B15. Determine the command to do that?

  Difference between formulas and functions

Assume your mother in law heard that you prepared the budget for the high school reunion picnic and has asked if you could help her to make a monthly household budget.

  Find values of n insertion sort beat merge sort

For inputs of size n, insertion sort runs in 8n 2 steps, where as merge sort runs in 64* nlog base 2 n steps. For which values of n odes insertion sort beat merge sort?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd