Answer:
Explanation:
Its not a good practice to write all the functions including main() in the same class.
But as you opted for this, the code goes here like this:
public class CalcPyramidVolume {
/* Your solution goes here */
static double pyramidVolume(double baseLength, double baseWidth, double pyramidHeight)
{
double Volume,baseArea;
baseArea = baseLength * baseWidth;
Volume = baseArea * pyramidHeight * 1/3;
return Volume;
}
public static void main (String [] args) {
System.out.println("Volume for 1.0, 1.0, 1.0 is: " + pyramidVolume(1.0, 1.0, 1.0));
return;
}
}
And there is not caveat of integer division, as you are declaring all your variables of type double.