Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.util.Scanner; public class NthRootFinder { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // Read n (for taking the nth root)

image text in transcribed

import java.util.Scanner;

public class NthRootFinder { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // Read n (for taking the nth root) int n = Integer.parseInt(sc.nextLine()); // Read number to take the nth root of int number = Integer.parseInt(sc.nextLine()); // Read the desired precision int precision = Integer.parseInt(sc.nextLine()); // Print the answer System.out.println(findNthRoot(number, n, precision)); } private static String findNthRoot(int number, int n, int precision) { int lower=0; int upper=number; while (lower

Finish starter code

Add comments(beginner here)

Code in Java

(10 points) In this problem, we will implement an nth root finder. Re- call that the nth root of z, written "Vx, is the number when raised to the power n gives x. In particular, please fill in the findNthRoot (int number, int n, int precision) method in the class NthRootFinder. The method should return a string representing the nth root of number, rounded to the nearest precision decimal places. If your answer is exact you should fill in the answer with decimal places (i.e. with input 41 and precision 5, we should return 41.00000.) You may not use any library functions for this question In this question, the class NthRootFinder expects 3 lines, where the first line is n (the degree of root to take), the second line is a number, and the third number represents the precision. The output is a single line contain- ing the answer followed by a newline. For example, the following input would generate the output 20.000: 2 400 Additionally, the following input would generate the output 6.86: 2 47 2

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

Practical Database Programming With Visual Basic.NET

Authors: Ying Bai

1st Edition

0521712351, 978-0521712354

More Books

Students also viewed these Databases questions

Question

4. How is culture a contested site?

Answered: 1 week ago