@@ -76,17 +76,25 @@ 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+ * Calculate the surface area of a pyramid with a square base .
80+ *
81+ * @ param sideLength side length of the square base
82+ * @ param slantHeight slant height of the pyramid
83+ * @ return surface area of the given pyramid
84+ */
85+ public static double surfaceAreaPyramid (final double sideLength , final double slantHeight ) {
86+ if (sideLength <= 0 ) {
87+ throw new IllegalArgumentException ("Must be a positive sideLength" );
88+ }
89+ if (slantHeight <= 0 ) {
90+ throw new IllegalArgumentException ("Must be a positive slantHeight" );
91+ }
92+ double baseArea = sideLength * sideLength ;
93+ double lateralSurfaceArea = 2 * sideLength * slantHeight ;
94+ return baseArea + lateralSurfaceArea ;
95+ }
96+ }
97+
9098
9199 /**
92100 * Calculate the area of a rectangle.
@@ -235,21 +243,3 @@ public static double surfaceAreaCone(final double radius, final double height) {
235243
236244
237245 /**
238- * Calculate the surface area of a pyramid with a square base.
239- *
240- * @param sideLength side length of the square base
241- * @param slantHeight slant height of the pyramid
242- * @return surface area of the given pyramid
243- */
244- public static double surfaceAreaPyramid (final double sideLength , final double slantHeight ) {
245- if (sideLength <= 0 ) {
246- throw new IllegalArgumentException ("Must be a positive sideLength" );
247- }
248- if (slantHeight <= 0 ) {
249- throw new IllegalArgumentException ("Must be a positive slantHeight" );
250- }
251- double baseArea = sideLength * sideLength ;
252- double lateralSurfaceArea = 2 * sideLength * slantHeight ;
253- return baseArea + lateralSurfaceArea ;
254- }
255- }
0 commit comments