From fd30fdfc798526cafda68a0b3a3ffded4ea42c36 Mon Sep 17 00:00:00 2001 From: Bmasoudd <149185931+Bmasoudd@users.noreply.github.com> Date: Wed, 22 Oct 2025 10:36:43 -0400 Subject: [PATCH 1/2] Update Area.java --- .../java/com/thealgorithms/maths/Area.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/com/thealgorithms/maths/Area.java b/src/main/java/com/thealgorithms/maths/Area.java index 7a06fd5e5fa0..f927ea45c688 100644 --- a/src/main/java/com/thealgorithms/maths/Area.java +++ b/src/main/java/com/thealgorithms/maths/Area.java @@ -6,6 +6,24 @@ public final class Area { private Area() { } +/** + * 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; +} /** * String of IllegalArgumentException for radius From 3fd66698b2a845e50e31e8c0fae0246e9db4098b Mon Sep 17 00:00:00 2001 From: Bmasoudd <149185931+Bmasoudd@users.noreply.github.com> Date: Wed, 22 Oct 2025 10:44:04 -0400 Subject: [PATCH 2/2] Update Area.java --- .../java/com/thealgorithms/maths/Area.java | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/thealgorithms/maths/Area.java b/src/main/java/com/thealgorithms/maths/Area.java index f927ea45c688..5613ecab096a 100644 --- a/src/main/java/com/thealgorithms/maths/Area.java +++ b/src/main/java/com/thealgorithms/maths/Area.java @@ -6,25 +6,6 @@ public final class Area { private Area() { } -/** - * 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; -} - /** * String of IllegalArgumentException for radius */ @@ -210,4 +191,23 @@ public static double surfaceAreaCone(final double radius, final double height) { } return Math.PI * radius * (radius + Math.pow(height * height + radius * radius, 0.5)); } + /** + * 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; +} + }