File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
src/main/java/com/thealgorithms/audiofilters Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -46,3 +46,21 @@ public double[] apply(double[] audioSignal) {
4646 return emaSignal ;
4747 }
4848}
49+ /**
50+ * Calculate the surface area of a pyramid with a square base.
51+ *
52+ * @param sideLength side length of the square base
53+ * @param slantHeight slant height of the pyramid
54+ * @return surface area of the given pyramid
55+ */
56+ public static double surfaceAreaPyramid (final double sideLength , final double slantHeight ) {
57+ if (sideLength <= 0 ) {
58+ throw new IllegalArgumentException ("Must be a positive sideLength" );
59+ }
60+ if (slantHeight <= 0 ) {
61+ throw new IllegalArgumentException ("Must be a positive slantHeight" );
62+ }
63+ double baseArea = sideLength * sideLength ;
64+ double lateralSurfaceArea = 2 * sideLength * slantHeight ;
65+ return baseArea + lateralSurfaceArea ;
66+ }
You can’t perform that action at this time.
0 commit comments