Skip to content

Commit 41311ab

Browse files
Esteban RamirezEsteban Ramirez
authored andcommitted
feat: implement algorithm changes
1 parent 2319794 commit 41311ab

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

  • src/main/java/com/thealgorithms/maths

‎src/main/java/com/thealgorithms/maths/Area.java‎

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,7 @@ public static double surfaceAreaSphere(final double radius) {
7676
* @param slantHeight slant height of the pyramid
7777
* @return surface area of the given pyramid
7878
*/
79-
public static double surfaceAreaPyramid(final double sideLength, final double slantHeight) {
80-
if (sideLength <= 0) {
81-
throw new IllegalArgumentException("");
82-
}
83-
if (slantHeight <= 0) {
84-
throw new IllegalArgumentException("slant height must be greater than 0");
85-
}
86-
double baseArea = sideLength * sideLength;
87-
double lateralSurfaceArea = 2 * sideLength * slantHeight;
88-
return baseArea + lateralSurfaceArea;
89-
}
79+
9080

9181
/**
9282
* Calculate the area of a rectangle.
@@ -232,4 +222,15 @@ public static double surfaceAreaCone(final double radius, final double height) {
232222
}
233223
return Math.PI * radius * (radius + Math.pow(height * height + radius * radius, 0.5));
234224
}
235-
}
225+
public static double surfaceAreaPyramid(final double sideLength, final double slantHeight) {
226+
if (sideLength <= 0) {
227+
throw new IllegalArgumentException("Must be a positive sideLength");
228+
}
229+
if (slantHeight <= 0) {
230+
throw new IllegalArgumentException("Must be a positive slantHeight");
231+
}
232+
double baseArea = sideLength * sideLength;
233+
double lateralSurfaceArea = 2 * sideLength * slantHeight;
234+
return baseArea + lateralSurfaceArea;
235+
236+
}

0 commit comments

Comments
 (0)