A parallelogram is a special type of quadrilateral that has equal and parallel opposite sides. The diagonals of a parallelogram bisect each other at 90 degrees. The area of a figure can be defined in geometry as the space occupied by a flat shape. A figure’s area is the number of unit squares that cover a closed figure’s surface. Using its base and height, the parallelogram area can be computed. Apart from it, the area of a parallelogram can also be evaluated, if the length of the parallel sides is known, along with any of the angles between the sides.
Approach 1: Parallelogram Area Using Sides.
Suppose a and b are the set of parallel sides of a parallelogram and h is the height, then based on the length of sides and height of it, the formula for its area is given by:
Area = Base × Height
Area = b × h
Example:
Input : base = 4, height = 6 Output: area = 24 Input : base = 10, height = 15 Output: area = 150
Approach:
- Take two input as base and height of Parallelogram.
- Apply the area of Parallelogram formula to calculate the area.
- Print the area.
Below is the implementation of the above approach:
Java
// Java Program to Find the Area of Parallelogram import java.io.*; class GFG { public static void main(String[] args) { double base = 30.00 ; double height = 40.25 ; // formula for calculating the area double area_parallelogram = base * height; // displaying the area System.out.println( "Area of the parallelogram = " + area_parallelogram); } } |
Area of the parallelogram = 1207.5
Approach 2: Parallelogram Area Without Height.
If the height of the parallelogram is unknown to us, then we can use the trigonometry concept to find the area.
Area = ab sin (x)
Where a and b are the length of parallel sides and x is the angle between the sides of the parallelogram.
Example:
Input : length = 4, breadth = 6, angle(in degrees) = 30 Output: area = 11.999999999999998 Input : length = 5, breadth = 8, angle(in degrees) = 45 Output: area = 28.2842712474619
Approach:
- Take three input as length, breadth and angle between the sides of the Parallelogram.
- Apply the area of trapezium formula to calculate the area.
- Print the area.
Below is the implementation of the above approach:
Java
// Java Program to Find the Area of Parallelogram import java.io.*; class GFG { public static void main(String[] args) { double length = 10.00 ; double breadth = 16.00 ; int angle = 60 ; double sin_x = Math.sin(Math.toRadians(angle)); // formula for calculating the area double area_parallelogram = length * breadth * sin_x; // displaying the area System.out.println( "Area of the parallelogram = " + area_parallelogram); } } |
Area of the parallelogram = 138.56406460551017
Time complexity: O(1) because constant operations are being done
Auxiliary space: O(1)