Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that computes the nth root of a number. Given a real number X gr

ID: 3529938 • Letter: W

Question

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 ZY = 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 times 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. Solve this problem with methods. . After it runs as a console program, using the graphics example from my website as a guide, convert this program to a graphics program. To debug your compiled program use System.out.println() to follow intermediate values of your variables to see where your code does not follow the algorithm.

Explanation / Answer

import java.util.Scanner;
public class computeTenToThe
{
public static void main(String[] args)
{
System.out.println("Enter an integer for z:");
Scanner keyboard = new Scanner(
System.in);
int z = keyboard.nextInt( );
System.out.println("Enter an integer for y:");
int y = keyboard.nextInt( );
System.out.println(z*y);
System.out.println(z+y);
System.out.println(z-y);
System.out.println(z/y);
}

or you can also use this function

public static double root(double num, double root)

{

return Math.pow(Math.E, Math.log(num)/root);

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote