Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Java Program to Find the Area of Rhombus

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

A rhombus is a quadrilateral whose four sides all have the same length and a 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

Time complexity: O(1) since performing constant operations.

Space complexity: O(1)

My Personal Notes arrow_drop_up
Last Updated : 03 Aug, 2022
Like Article
Save Article
Similar Reads
Related Tutorials