Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class MySqrtMethod ( public static void main(String[] args) { } // read in the command-line argument double x Double.parseDouble (args[0]); /* Newton's method

image text in transcribedimage text in transcribed

public class MySqrtMethod ( public static void main(String[] args) { } // read in the command-line argument double x Double.parseDouble (args[0]); /* Newton's method to calculate square root of a positive number */ double y = x; // The initial estimate of the square root of x; very rough double epsilon - 1E-15; // Floating-point error bound while (Math.abs(y - x/y) > Math.max(y, x/y)*epsilon) { y (x/y + y) / 2.0; } // Print out the estimate of the square root of x // and the square root calculated using the Math function System.out.println("Newton' Method: "+y); System.out.println("Math function: " + Math.sqrt(x)); Exercise 1: Code refactoring to define a method Dead that the file. The program calcula quare me of a positive narherraken from omand he seng Nowto's method, with a comparten in the square mancalcald by the Ja Na fonction Sampleram of the program me a felke jove redov Atte: 3.4 Hat Fertion 3.0 avd. 15. Horten Metho: 33353132597 Hath function: 1953 jove dar 3.7 He the S Hath function: 3.26233255123179 Your takistactor the code to deficacehoda pod below: xblic static ale sertboble) The actor program will take the newly defined method is felows: public class Myrth F //read in the mand-line aquat double Double parzedouble (192 Prist at the estimate of the agure ront of x and the square root calmalated wing the Math function. Dystout printintos method:get(): petem.out.println("a 17 and your conte retur : zaters y function: Mith.eartb Exercise 2: Code refactoring to define a class Following the cration of the sqrt marted in the presiun esorcise, we will refacter the program to define a class that contains the sqrt mated. Makey of the pregnen. MySer Methed, Jana from Exercise to new file called Myerta ja Follow the following stat 1. 2 the the clasa altyartApp: 3 nove the code or sqrt marted to the clu 4 call the method in your newly cried Mathlab chx to calculac f That you need progons for comotress, shin should now be called MySqrips, jove. The courget of the programs should be the same as they method pogone as follows jawa yam News Ited: 3.6 Mach functie 3.6 Jaya 11.3 MH 464) Math function: 3.0408353168337 Jana Mysga 15.7 Nethe: 3.5623225512333834 Math foriem 3.12225917519 Exercise & Quadratic formula The quadra is the solution of de quadratic equation as wpress known valse stile a. and a contact with is not equal to 0. The quatic Socis expressed as I= Whitepla do stop, jene to take the integer vakes of c, bude fun the command line and find out the solutions wing fresquarstic form. You should use the sert metal za cested in gran Math in class in Frise 2.Copy Rib das who madikation to your propem the cornegrise, the arend solutions. In todisainiere is sqad to, the artwoogal solations Otherwise, then we vodkintal slations. The aparities of the code is bed in Jewing UML Marks: td - Aac) a negative, there are so I the campaika 0, we are two aqua, akaans. Other the wodacimal. The agterto thelling UML lyc no real solutions The flowing plena de programs in show how the capai sauld be pre-med. jawa Ceratop-1434-1 wwwQuadratilpp.1234 Java Custratoppja 16 1 4.25 Java Ceratopp-1-712 234.8 32-1.9 ++ 3 Tuk Exci Exercise 2 Exercise) 442 Mask 03 05

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

Elementary Linear Algebra with Applications

Authors: Howard Anton, Chris Rorres

9th edition

471669598, 978-0471669593

More Books

Students also viewed these Programming questions

Question

Use Formula 11 to show that date-a- sino=e16-e-m and

Answered: 1 week ago