Skip to content

Commit c6326c8

Browse files
committed
changes
1 parent b312567 commit c6326c8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/main/java/com/thealgorithms/audiofilters/EMAFilter.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
}

0 commit comments

Comments
 (0)