File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
src/main/java/com/thealgorithms/maths Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -102,4 +102,15 @@ public static double volumePyramid(double baseArea, double height) {
102102 public static double volumeFrustumOfCone (double r1 , double r2 , double height ) {
103103 return (Math .PI * height / 3 ) * (r1 * r1 + r2 * r2 + r1 * r2 );
104104 }
105+
106+ /**
107+ * Calculate the volume of a frustum of a pyramid.
108+ *
109+ * @param upperBaseArea area of the upper base
110+ * @param lowerBaseArea area of the lower base
111+ * @param height height of the frustum
112+ * @return volume of the frustum
113+ */
114+ public static double volumeFrustumOfPyramid (double upperBaseArea , double lowerBaseArea , double height ) {
115+ return (upperBaseArea + lowerBaseArea + Math .sqrt (upperBaseArea * lowerBaseArea )) * height / 3 ;
105116}
You can’t perform that action at this time.
0 commit comments