Skip to content

# Java Program to Find the Area of Rhombus

• Last Updated : 23 Aug, 2021

A rhombus is a quadrilateral whose four sides all have the same length and rhombus is also called an equilateral quadrilateral.

The formula for finding the area of a rhombus is as follows:

(product of the lengths of the diagonals)/2

Example:

```Input : p = 2, q = 3
Output: 3

Input : p = 4, q = 5
Output: 10```

Implementation:

## Java

 `// Java Program to Find the Area of Rhombus` `public` `class` `AreaOfRhombus {` `    ``public` `static` `void` `main(String[] args)` `    ``{` `        ``double` `d1, d2;` `        ``// Diagonal 1` `        ``d1 = ``2``;` `        ``// Diagonal 2` `        ``d2 = ``3``;` `        ``if` `(d1 <= ``0` `|| d2 <= ``0``)` `            ``System.out.println(``"Length should be positive"``);` `        ``else` `            ``System.out.println(``"Area of rhombus = "` `                               ``+ (d1 * d2) / ``2``);` `    ``}` `}`

Output

`Area of rhombus = 3.0`

My Personal Notes arrow_drop_up
Recommended Articles
Page :