write a program that computes the nth root of a number. given a real number X greater than 1 and less than -1 and given an integer Y, compute the nth root Z such that Z*Z*Z*Z*Z*Z*Z...(Y times)..Z*Z=X, or Z^y=X(Remember if X is negative Y must be odd.) The user enters values for X and Y and the program calculates Z. Compute Z so that when Z is multiplied Y time it will produce an X which is + or - 0.0000001 of the original value of X. You may only use simple arithmetic to do these computations. That is you may only use multiplication, division, addition, and subtraction. Do it using three methods and implement it 2 ways: one as a static method and one as an instance of the class.
lilpinay
0
Newbie Poster
Recommended Answers
Jump to Postok, so what have you done so far?
post some code I can help you clear the problems, not do your homework for you.
Jump to Postpublic static double nRoot(int n, double num, double epsilon) { //if you weren't sure, epsilon is the precision int ctr = 0; double root = 1; if(n <= 0) return Double.longBitsToDouble(0x7ff8000000000000L); //0x7ff8000000000000L is the Java constant for NaN (Not-a-Number) if(num == 0) //this step is just to …
All 5 Replies
finito
46
Nearly a Posting Virtuoso
lilpinay
0
Newbie Poster
siamsoft
0
Newbie Poster
finito
46
Nearly a Posting Virtuoso
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.