import java.io.*;
import java.util.*;
public class volumeConeD
{//class
public static void main (String [] args)
{//main
Scanner keyBoard = new Scanner(System.in);//input for keyBoard
//variables
double volume;
double radius;
double hieght;
double pie = 3.14;
double yes = 1.0;
boolean volumeTwo = true;
while(volumeTwo == 0){
System.out.print("Volume of a Cone... V=1/3(3.14)r^2(h)");
System.out.println ();
System.out.println ();
radius = getRadius(radius); //call to method
System.out.print("Enter a Height ");
hieght = keyBoard.nextDouble ();
//math
volume = .33333 * pie * radius * radius * hieght;
System.out.printf ("Volume = " + volume);
}//end of while
}//end of main
public static double getRadius (double radius)
{
Scanner keyBoard = new Scanner(System.in);
System.out.print("Enter Radius Squared Number ");
radius = keyBoard.nextDouble ();
return radius;
}
}//end of program
所以这是我的问题。我必须写这个,以便如果答案最终是 Volume = 0 程序必须结束。我必须使用 while 循环和该方法来输入半径。我不断收到这个错误,我不知道为什么。
error
volumeConeD.java:25: error: incomparable types: boolean and int
while(volumeTwo == 0){
^
1 error.
我理解错误的含义,但我不知道如何修复它。请帮助新编辑......也在它必须读取的while循环中,while(Volume == 0)。