Hello everyone, welcome to my new tutorial on **Java Program to calculate Area of Trapezium. **The trapezium is a quadrilateral with one pair of parallel opposite sides. The parallel sides of a trapezium are called bases, and the non-parallel sides of a trapezium are called legs.

In the previous tutorial, you have learned Java Program to Calculate Area and Perimeter of Parallelogram. In this tutorial, you will get the answer to your query – how do you find the area of a trapezium in Java?

The area of a trapezium can be calculated using the following formula.

Area of a Trapezium, A = h(a+b)/2

Where,

**a**and**b**are the bases of the Trapezium**h**is the altitude or height of the Trapezium.

Now let’s write the program, and explanations are given after the program.

## Java Program to Calculate Area of Trapezium

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import java.util.*; public class Trapezium { public static void main(String[] args) { double a1, a2, h, area; Scanner in = new Scanner(System.in); // Asking the user to enter the base1, base2 and height of the trapezium System.out.println(" Enter the base1, base2 and height of the trapezium :"); a1 = in.nextDouble(); a2 = in.nextDouble(); h = in.nextDouble(); area = ((a1+a2)*h)/2; // Calculating area of Trapezium System.out.println(" Area of Trapezium : " + area +" square units"); } } |

**What we did?**

- First of all we have imported the util package.
- Then created a class and named it Trapezium.
- After that started main() method of the program.
- Then inside main() method declared variables.
- Then created object of the Scanner class.
- Now asked the user to enter the base1, base2, and height of the trapezium. Then read the value of base1, base2, and height of trapezium entered by the user.
- Then calculated area of the trapezium using the formula
**area = ((a1+a2)*h)/2** - Then finally displayed the value of area of the trapezium on the screen.

Now let’s check the output of the above code.

**Output:**

1 2 3 |
Enter the base1, base2 and height of the trapezium : 2 3 4 Area of Trapezium : 10.0 square units |

Now this tutorial on **Java Program to calculate Area of Trapezium **is completed. In the next tutorial, you will learn Java Program to calculate Area and Volume of Cube.

**Related Tutorials…**

- Java Program to Calculate Area and Circumference of Circle
- Java Program to calculate Area of Triangle
- Java Program to calculate Area of Triangle using heron’s formula
- Java Program to calculate Area and Perimeter of Right Triangle
- Java Program to calculate Area and Perimeter of Rectangle
- Java Program to calculate Area and Perimeter of Square
- Java Prorgram to calculate Area and Perimeter of Parallelogram
- Java Program to calculate Area and Volume of Cuboid
- Java Program to calculate Total Surface Area and Curved Surface Area of cylinder
- Java Program to calculate Volume of Cone
- Java Program to calculate Surface Area and Volume of Sphere