Skip to content
Related Articles
Java Program to Find the Area of Trapezium
• Difficulty Level : Expert
• Last Updated : 22 Dec, 2020

A trapezium is a convex quadrilateral, which has only two parallel sides and the other two sides are non-parallel. The non-parallel sides of the trapezium are referred to as its legs while the parallel sides are called the bases. It is also called a trapezoid. A parallelogram is also often referred to as a trapezoid with two parallel sides.

In the figure below, AB and DC are parallel to each other while AD and BC are the non-parallel sides. ‘h’ is also the distance that indicates the height of the trapezium between the two parallel sides. Area of trapezium:

`Area = 1/2*(sum of parallel sides)*height of the trapezium`

Example:

```Input : base1 = 3, base2 = 4, height = 6
Output: area = 21

Input : base1 = 5, base2 = 7, height = 3
Output: area = 18```

Approach:

1. Take three input as two bases of the trapezium and height.
2. Apply the area of the trapezium formula to calculate the area.
3. Print the area.

Below is the implementation of the above approach:

## Java

 `// Java Program to Find the Area of Trapezium`` ` `import` `java.io.*;`` ` `class` `GFG {``    ``public` `static` `void` `main(String[] args)``    ``{``        ``double` `base_1 = ``10.00``;`` ` `        ``double` `base_2 = ``20.00``;`` ` `        ``double` `height = ``50.00``;`` ` `        ``// formula for calculating the area``        ``double` `area_of_trapezium``            ``= ((base_1 + base_2) * height) / ``2``;`` ` `        ``// printing the area``        ``System.out.println(``"Area of trapezium:"``                           ``+ area_of_trapezium);``    ``}``}`
Output
`Area of trapezium:750.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