22 Jul java lab19
This lab project is due on Friday, March 31, 2017 at 12:00 PM (noon),
The Babylonian Algorithm for Square Root Approximation
Perhaps the first algorithm used for approximating the square root of S is known as the “Babylonian method”, named after the Babylonians, or “Heron’s method”, named after the first-century Greek mathematician Heron of Alexandria who gave the first explicit description of the method. It can be derived from (but predates by 16 centuries) Newton’s method.
The basic idea is that if x is an overestimate to the square root of a non-negative real number S then S/x will be an underestimate and so the average of these two numbers may reasonably be expected to provide a better approximation. More precisely, assuming S is a positive number:
1. Make a guess at the answer (you can pick S/2 as your initial guess).
2. Compute r = S / guess.
3. Set new guess = (guess + r) / 2
4. Go back to step 2 until the last two guess values are within 1% of each other1.
To complete this lab project:
1. Create a new NetBeans project named CPS150_Lab19.
2. Delete the auto-generated CPS150_Lab19.java source file in the new project.
3. Download and import the replacement CPS150_Lab19.java source file into your project. If needed, refer to the online instructions on importing a Java source file into a NetBeans project.
4. Add your section number in the top comment block:
/* * CPS 150 * Algorithms & Programming I * * Section *** enter your section number here *** * Spring 2017 */
5. Add your name in the comment block after the @author tag:
/** * Lab Project 19 * The Babylonian Algorithm * * @author */
6. Complete the method definitions for the following methods in CPS150_Lab19.java:
· static double getInput(double min)
· static double sqrt(double S)
Notes
1. See Section 5.8 (Floating-point comparison) in Chapter 5 (Java Branches) of the course zyBook.
Sample Run (user input highlighted):
run: Enter a number greater or equal to 1.0: hello Invalid data type (not numeric) Enter a number greater or equal to 1.0: -6 Invalid value (too small) Enter a number greater or equal to 1.0: 0 Invalid value (too small) Enter a number greater or equal to 1.0: 10 The square root of 10.00 is 3.16 BUILD SUCCESSFUL (total time: 12 seconds
Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.
About Writedemy
We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.
How It Works
To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Are there Discounts?
All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.
