Area of Trapezoid
previous NextExample 2
import java.util.Scanner;
class Raj{
public static void main(String[] args) {
int b1;
int b2;
int h;
float area;
Scanner sc = new Scanner(System.in);
System.out.print("\nEnter value of bases:");
b1 = sc.nextInt();
b2 = sc.nextInt();
System.out.print("\nEnter the value of the height:");
h = sc.nextInt();
area = (float)((b1+b2) * h)/2;
System.out.print("\nArea of a trapezoid :"+area);
}
}
Output :
Enter the value of bases:5 10 Enter the value of the height:12
Area of a trapezoid :90.0