Java Program to Find the Area of Trapezium
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
Input : base1 = 3, base2 = 4, height = 6 Output: area = 21
Input : base1 = 5, base2 = 7, height = 3 Output: area = 18
- Take three input as two bases of the trapezium and height.
- Apply the area of the trapezium formula to calculate the area.
- Print the area.
Below is the implementation of the above approach:
Area of trapezium:750.0
Time complexity: O(1) // since performing constant operations
Space complexity: O(1)