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; + } }