Skip to content
Related Articles

Related Articles

Improve Article
Java Program to Find the Area of Rhombus
  • Last Updated : 04 Dec, 2020

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 positve");
        else
            System.out.println("Area of rhombus = "
                               + (d1 * d2) / 2);
    }
}
Output
Area of rhombus = 3.0

Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :