Question: Approximating Roots (50 points) In this problem, we will implement a square root approximator and then an nth root approximator. Recall that the nth

Approximating Roots (50 points) In this problem, we will implement a square root approximator and then an nth root approximator. Recall that the nth

Approximating Roots (50 points) In this problem, we will implement a square root approximator and then an nth root approximator. Recall that the nth root of a non-negative x, written , is the non-negative number y when raised to the power n gives x. We learned in class that we can use the concept of binary search to approximate the square root of a number, and we can continue this logic to approximate the nth square root. We're going to use the concept of binary search to try and approximate finding the square root and finding the nth root. You may not use any library functions for these tasks, except DecimalFormat. (a) Implement the method squareRootFinder (int number, int iterations). The method should return a string representing an approximation of the square root of the number with 5 decimal places. For example: squareRoot Finder(9, 2) means that we want to approximate the square root of 9 with two iterations of binary search. We know that the square root of 9 must be between 0 and 9. Thus, let the range that we look at be [0,9]. Its midpoint is 4.5. (4.5)2 is equal to 20.25. 20.25 is too high because it's greater than 9. Thus, we now set our range to [0, 4.5]. The middle is now 2.25. (2.25)2 is equal to 5.0625, which is now too low since 1 CSC 3320: Syst x Your answer is X D2L Feedback for X > HW2 (1).pdf > Lab04.pdf Homework He X C In this assignm X C Please use Sim D2L Assignments + 0 X > File C:/Users/14049/Downloads/HW2%20(1).pdf * H Update M Gmail YouTube = HW2 (1).pdf 1 Maps News 2 Translate Diagnostic Quiz: Ge... Degree evaluation r... Degree evaluation r... D2L y 2 / 2 100% + | Implement.java HW2 (1).pdf PDF HW2.pdf 78F Sunny Q it's less than 9. We did 2 iterations. Thus, our best guess for the square root is 2.25000 (remember, 5 decimal point accuracy). If we were doing 3 iterations, we'd now set our new range to [2.25, 4.5]. (b) Implement the method nth RootFinder (int number, int iterations, int n). Now we're approximating the nth root of our number. Recall that the nth root of x, written "x, is the number y when raised to the power n gives x. For example, the cubed root of 64 is 364 which is equal to 4, since 43 = 64. You'll use the same binary search method as described in part (a) for squareRootFinder, but now you're checking to see if it's the nth root. For example: nth RootFinder (64, 1, 3) is trying to approximate the cubed. root of 64 with only one iteration of binary search. Hint: the code for nth Root Finder looks just like the code for squareRootFinder, but contains a few more lines of code. Remember, you may not use any library functions for these tasks, except DecimalFormat. (c) Call these methods in this order with the following inputs: squareRootFinder (41, 5), nthRootFinder (41, 3, 3). Each individ- ual result must be output and appear in a single line. Example output for the input above: 6.40625 5.12500 Note: Your methods must return correct results even for different inputs. Good luck! lab 2 (1).docx implementation (1).java PDF Lab04 dt.pdf ^ >>> Show all 8:32 PM 9/18/2022 D

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

CODE import javatextDecimalFormat class Main public static double multiplydouble midint n TO mu... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!