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
17 changes: 17 additions & 0 deletions src/main/java/com/thealgorithms/maths/Area.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,21 @@
}
return Math.PI * radius * (radius + Math.pow(height * height + radius * radius, 0.5));
}
* Calculate the surface area of a pyramid with a square base.

Check failure on line 235 in src/main/java/com/thealgorithms/maths/Area.java

View workflow job for this annotation

GitHub Actions / build

<identifier> expected

Check failure on line 235 in src/main/java/com/thealgorithms/maths/Area.java

View workflow job for this annotation

GitHub Actions / build

';' expected

Check failure on line 235 in src/main/java/com/thealgorithms/maths/Area.java

View workflow job for this annotation

GitHub Actions / build

';' expected

Check failure on line 235 in src/main/java/com/thealgorithms/maths/Area.java

View workflow job for this annotation

GitHub Actions / build

';' expected

Check failure on line 235 in src/main/java/com/thealgorithms/maths/Area.java

View workflow job for this annotation

GitHub Actions / build

';' expected

Check failure on line 235 in src/main/java/com/thealgorithms/maths/Area.java

View workflow job for this annotation

GitHub Actions / build

';' expected

Check failure on line 235 in src/main/java/com/thealgorithms/maths/Area.java

View workflow job for this annotation

GitHub Actions / build

illegal start of type

Check failure on line 235 in src/main/java/com/thealgorithms/maths/Area.java

View workflow job for this annotation

GitHub Actions / AnalyzeJava

<identifier> expected

Check failure on line 235 in src/main/java/com/thealgorithms/maths/Area.java

View workflow job for this annotation

GitHub Actions / AnalyzeJava

';' expected

Check failure on line 235 in src/main/java/com/thealgorithms/maths/Area.java

View workflow job for this annotation

GitHub Actions / AnalyzeJava

';' expected

Check failure on line 235 in src/main/java/com/thealgorithms/maths/Area.java

View workflow job for this annotation

GitHub Actions / AnalyzeJava

';' expected

Check failure on line 235 in src/main/java/com/thealgorithms/maths/Area.java

View workflow job for this annotation

GitHub Actions / AnalyzeJava

';' expected

Check failure on line 235 in src/main/java/com/thealgorithms/maths/Area.java

View workflow job for this annotation

GitHub Actions / AnalyzeJava

';' expected

Check failure on line 235 in src/main/java/com/thealgorithms/maths/Area.java

View workflow job for this annotation

GitHub Actions / AnalyzeJava

illegal start of type
*
* @param sideLength side length of the square base

Check failure on line 237 in src/main/java/com/thealgorithms/maths/Area.java

View workflow job for this annotation

GitHub Actions / build

';' expected

Check failure on line 237 in src/main/java/com/thealgorithms/maths/Area.java

View workflow job for this annotation

GitHub Actions / build

';' expected

Check failure on line 237 in src/main/java/com/thealgorithms/maths/Area.java

View workflow job for this annotation

GitHub Actions / build

';' expected

Check failure on line 237 in src/main/java/com/thealgorithms/maths/Area.java

View workflow job for this annotation

GitHub Actions / AnalyzeJava

';' expected

Check failure on line 237 in src/main/java/com/thealgorithms/maths/Area.java

View workflow job for this annotation

GitHub Actions / AnalyzeJava

';' expected

Check failure on line 237 in src/main/java/com/thealgorithms/maths/Area.java

View workflow job for this annotation

GitHub Actions / AnalyzeJava

';' expected
* @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;
}
}
Loading