I’m making this program for a class and I need to guess a number’s cube root. Here’s my code:
int N = Integer.parseInt(args[0]);
//sets the guess at 1.0
guess = 1.0;
//whether or not the guess is close to N
while (guess * guess * guess <= N ){
double show = (guess + ((1/3) * ((N / (guess * guess)) - guess)));
System.out.println(show);
guess = show;
continue;
}
However, every time I run this program, the double show is always set to the value 1. Can anyone please tell me why this is happening and how I can fix it?
because 1/3 is integer division and that is always 0. It should be