From e62d94cfa3062134f4e4257a3969cf0b53cde466 Mon Sep 17 00:00:00 2001 From: why-GitHup Date: Fri, 30 Oct 2026 12:29:44 -0400 Subject: [PATCH] added area calculation for a rhombus --- src/main/java/com/thealgorithms/maths/Area.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/com/thealgorithms/maths/Area.java b/src/main/java/com/thealgorithms/maths/Area.java index 84fc67159379..033cf5bb6c22 100644 --- a/src/main/java/com/thealgorithms/maths/Area.java +++ b/src/main/java/com/thealgorithms/maths/Area.java @@ -232,4 +232,21 @@ 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 area of a rhombus. + * + * @param diagonal1 length of the first diagonal + * @param diagonal2 length of the second diagonal + * @return area of given rhombus + */ + public static double surfaceAreaRhombus(final double diagonal1, final double diagonal2) { + if (diagonal1 <= 0) { + throw new IllegalArgumentException("Diagonal 1 must be greater than 0"); + } + if (diagonal2 <= 0) { + throw new IllegalArgumentException("Diagonal 2 must be greater than 0"); + } + return diagonal1 * diagonal2 / 2; + } }