Java Program to Find Area Of Trapezoid

Here is a Java Program to find the area of Trapezium. Given the length of parallel sides of a trapezoid and the height of the trapezoid(distance between the parallel side), we have to find the area of given trapezoid. In North America, A trapezium is referred to as a trapezoid.

A trapezium is a quadrilateral with at least one pair of parallel sides, other two sides may or may not be parallel. The parallel sides are called the bases of the trapezium and the other two sides are called it's legs. The perpendicular distance between parallel sides is called height of trapezium.

Area of Trapezium
The area of a Trapezoid is the amount of two-dimensional space inside it's boundary.
Area of Trapezoid = 1/2 X (X + Y) X H
Where X and Y are the length of parallel sides of Trapezoid and H is perpendicular distance between the parallel sides.

Java program to find the area of trapezoid

In this java program, we first take the length of parallel sides and height of trapezoid as input from user and store then in variable side1, side2, height. Then we calculate the area of given trapezoid as mentioned above and store it in varaible "area". Finally we print the area of trapezoid on screen.

package com.tcc.java.programs;

import java.util.Scanner;

public class AreaOfTrapizoid {

    public static void main(String[] args) {
        double side1, side2, height, area;
        Scanner scanner;
        scanner = new Scanner(System.in);

        // Take input from user
        System.out.println("Enter Length of Two 
            Parallel Sides of Trapezium");
        side1 = scanner.nextDouble();
        side2 = scanner.nextDouble();
        System.out.println("Enter Height of Trapezium");
        height = scanner.nextDouble();

        area = 1.0 / 2 * (side1 + side2) * height;

        System.out.format("Area of Trapezium = %.2f\n", area);
    }
}
Output
Enter Length of Two Parallel Sides of Trapezium
7 6
Enter Height of Trapezium
3
Area of Trapezium = 19.50
Important properties of trapezium
  • A pair of opposite sides of a trapezium are parallel.
  • As a pair of sides are parallel. Hence, The angle between a side and diagonal is equal to the angle between the opposite parallel side and the diagonal.
  • The sum of the two adjacent angles of a trapezium is 180 degrees.
  • The cosines(cos) of two adjacent angles sum to 0. As adjacent angles are supplementary.

Recommended Posts
Java Program to Find Area Of Triangle
Java Program to Find Area of Right Angled Triangle
Java Program to calculate area and circumference of circle
Java Program to find Area Of Equilateral Triangle
Java Program to Calculate Volume of Sphere
Java Program to Find Volume and Surface Area of Cuboid
Java Program to Calculate Surface Area and Volume of Cube
Java Program to Find Surface Area and Volume of Cylinder
Java Program to Calculate Volume and Surface Area of Cone
Java Program to Convert Celsius to Fahrenheit
Java Program to Convert Fahrenheit to Celsius
All Java Programs