Ok, in the equation z^y = x, I'm trying to find value of z(closest to .001)when values of y and x are given. It keeps getting stuck in a loop, and I don't know what the problem is.

Code:

public void process( )
{
double upperBound = x;
double lowerBound = 1;
int countY = 0;
xGuess = 1;
do
{
zGuess = (upperBound + lowerBound)/2;
while (xGuess < x && countY < y)
{
xGuess = zGuess * zGuess;
countY++;
}
if (xGuess > x)
upperBound = zGuess;
else lowerBound = zGuess;
if (x > xGuess)
difference = x - xGuess;
else difference = xGuess - x;
}while (difference > .001);
System.out.println("Answer is: " + zGuess);
}