Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/main/java/com/thealgorithms/maths/Area.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Find the area of various geometric shapes
*/
public final class Area {

private Area() {
}

Expand Down Expand Up @@ -69,7 +70,7 @@ public static double surfaceAreaSphere(final double radius) {
return 4 * Math.PI * radius * radius;
}

/**
/**
* Calculate the surface area of a pyramid with a square base.
*
* @param sideLength side length of the square base
Expand All @@ -78,16 +79,15 @@ public static double surfaceAreaSphere(final double radius) {
*/
public static double surfaceAreaPyramid(final double sideLength, final double slantHeight) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed this method

if (sideLength <= 0) {
throw new IllegalArgumentException("");
throw new IllegalArgumentException("Must be a positive sideLength");
}
if (slantHeight <= 0) {
throw new IllegalArgumentException("slant height must be greater than 0");
throw new IllegalArgumentException("Must be a positive slantHeight");
}
double baseArea = sideLength * sideLength;
double lateralSurfaceArea = 2 * sideLength * slantHeight;
return baseArea + lateralSurfaceArea;
}

/**
* Calculate the area of a rectangle.
*
Expand Down
Loading