Определите метод CalcPyramidVolume с двойными параметрами типа данных baseLength, baseWidth и PyramidHeight, который возвращает двойной объем пирамиды с прямоугольным основанием. CalcPyramidVolume() вызывает данный метод CalcBaseArea() при расчете.
Соответствующие уравнения геометрии:
Объем = базовая площадь x высота x 1/3
Площадь основания = длина основания x ширина основания.
(Остерегайтесь целочисленного деления).
Код: Выделить всё
public class CalcPyramidVolume {
public static double calcBaseArea(double baseLength, double baseWidth) {
return baseLength * baseWidth;
}
/* My code starts here */
static double calcpyramidVolume(double baseLength, double baseWidth,
double pyramidHeight) {
double Volume, baseArea;
baseArea = baseLength * baseWidth;
Volume = baseArea * pyramidHeight * 1 / 3;
return Volume;
}
/* End of my code */
public static void main (String [] args) {
Scanner scnr = new Scanner(System.in);
double userLength;
double userWidth;
double userHeight;
userLength = scnr.nextDouble();
userWidth = scnr.nextDouble();
userHeight = scnr.nextDouble();
System.out.println("Volume: " + calcPyramidVolume(userLength, userWidth, userHeight));
}
}
Код: Выделить всё
CalcPyramidVolume.java:28: error: cannot find symbol
System.out.println("Volume: " + calcPyramidVolume(userLength, userWidth, userHeight));
^
symbol: method calcPyramidVolume(double,double,double)
location: class CalcPyramidVolume
1 error
Подробнее здесь: https://stackoverflow.com/questions/793 ... ume-method
Мобильная версия