我正在为一个班级制作这个程序,我需要猜测一个数字的立方根。这是我的代码:
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;
}
但是,每次我运行这个程序时,双重显示总是设置为值 1。谁能告诉我为什么会发生这种情况以及如何解决它?