From bc18a393e0dbe05e10ac66ed17609effc6f01b25 Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 29 Oct 2026 16:17:52 -0400 Subject: [PATCH] Added my stuff --- .../java/com/thealgorithms/maths/Area.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Java/src/main/java/com/thealgorithms/maths/Area.java diff --git a/Java/src/main/java/com/thealgorithms/maths/Area.java b/Java/src/main/java/com/thealgorithms/maths/Area.java new file mode 100644 index 000000000000..6e39ab1041c8 --- /dev/null +++ b/Java/src/main/java/com/thealgorithms/maths/Area.java @@ -0,0 +1,19 @@ +/** +* Calculate the surface area of a pyramid with a square base. +* +* @param sideLength side length of the square base +* @param slantHeight slant height of the pyramid +* @return surface area of the given pyramid +*/ +public static double surfaceAreaPyramid(final double sideLength, final double slantHeight) { +if (sideLength <= 0) { +throw new IllegalArgumentException("Must be a positive sideLength"); +} +if (slantHeight <= 0) { +throw new IllegalArgumentException("Must be a positive slantHeight"); +} +double baseArea = sideLength * sideLength; +double lateralSurfaceArea = 2 * sideLength * slantHeight; +return baseArea + lateralSurfaceArea; + +} \ No newline at end of file