让call一个method来计算圆锥体积
可是在printf的时候显示volume cannot be resovled to a variable
怎么修改呢?
package volume;
import java.util.Scanner;
public class VolumeofCone {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.printf("Enter the radius of the cone:\n");
double radius = input.nextDouble();
System.out.printf("Enter the height of the cone:");
double height = input.nextDouble();
System.out.printf("The volume of cone with radius %.4f and height %.4f is:%.4f \n", radius, height, volume);
double volume = getVolume(radius, height);
}
public static double getVolume(double radius, double height) {
double volume = Math.PI * height * Math.pow(radius, 2) / 3;
{
return volume;
}
}
}