This is a Java Program to Find the Area of Trapezium.

Formula:

Area=0.5(sum of parallel sides) * distance between parallel sides

Formula:

Area=0.5(sum of parallel sides) * distance between parallel sides

Enter the length of parallel sides and distance between them as input. Now we calculate the area by using formula and get the desired output.

Here is the source code of the Java Program to Find the Area of Trapezium. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.

advertisement

import java.util.Scanner;

public class Trapezium

`{`

public static void main(String[] args)

`{`

int a, b, c;

double area;

Scanner s = new Scanner(System.in);

System.out.print("Enter the length of first parallel line:");

a = s.nextInt();

System.out.print("Enter the length of second parallel line:");

b = s.nextInt();

System.out.print("Enter the distance between parallel lines:");

c = s.nextInt();

area = 0.5 * (a + b) * c;

System.out.println("Area of trapezium:"+area);

`}`

`}`

Output:

$ javac Trapezium.java $ java Trapezium Enter the length of first parallel line:5 Enter the length of second parallel line:6 Enter the distance between parallel lines:4 Area of trapezium:22.0

**Sanfoundry Global Education & Learning Series – 1000 Java Programs.**

advertisement

Here’s the list of Best Reference Books in Java Programming, Data Structures and Algorithms.