The volume of an object is the total space occupied by that object. The volume of a cube is obtained by taking the product of three lengths of the cube.
volume = s * s * s
volume
: This represents the volume of the cube.s
: This represents the length of each side of the cube.# create function to get the volume of a cubedef getVolume(lengthOfSide)volume = lengthOfSide * lengthOfSide * lengthOfSideputs "The volume of cube with length of side #{lengthOfSide} is = #{volume}"end# create length of sides of cubesl1 = 23l2 = 5l3 = 0.5l4 = 100# get the volumes of the cubesgetVolume(l1)getVolume(l2)getVolume(l3)getVolume(l4)
getVolume()
, which takes the length of the side of a cube, calculates the volume, and prints the result to the console.