Respuesta :
Answer:
Following are the program in Python programming language
def pyramid_volume(base_length,base_width,pyramid_height):
base_area=base_length*base_width
volume=base_area*pyramid_height*(1/3)
return volume
print('volume for 4.5,2.1,3.0 is:',pyramid_volume(4.5,2.1,3.0))
Explanation:
Here, we define a function "pyramid_volume()" and pass an arguments "base_length,base_width,pyramid_height"
inside that program we have calculated the area of the pyramid and after that we have calculated the volume of that pyramid and return the volume.
Outside of the function we have called the function by passing the arguments.
The code below is in Java.
It calculates the volume of a pyramid by creating a function. The base length, base width, and pyramid height are passed as parameters to the function.
I also include the main part so that you can test it.
Comments are used to explain each line of code
//Main.java
public class Main
{
public static void main(String[] args) {
//Initialize the variables
double base_length = 4.5;
double base_width = 2.1;
double pyramid_height = 3.0;
//Call the the function with the given parameters
System.out.printf("Volume for %.1f, %.1f, %.1f is: %.2f", base_length, base_width, pyramid_height
, pyramid_volume(base_length, base_width, pyramid_height));
}
//function that takes length, width and height as parameters and returns the volume
public static double pyramid_volume(double base_length, double base_width, double pyramid_height) {
//calculate the base area by multiplying the base length and base width
double base_area = base_length * base_width;
//calculate the volume by multiplying the base area, pyramid height and 1/3
double volume = base_area * pyramid_height * (1.0/3);
return volume;
}
}
You may see another function example in the following link:
brainly.com/question/20814969