I have written a method in one class and wish to call it in another, i.e print the result. Here is the method's class:
public class squareRoot {
public double absoluteValue(double x){
if (x < 0)
x = -x;
return(x);
}
public double squareRoot(double x){
double epsilon = .00001;
double guess = 1.0;
while(absoluteValue(guess * guess - x) >= epsilon)
guess = (x / guess + guess) / 2.0;
return guess;
}
}
The second class is a simple gui class and I wish to call the squareRoot method. I obtain the user input and then try to print the function, like this (with x being the user input in the gui class). However it is not working
squareRoot(x);