import java.util.*;
public class TrapArea {
public static void main(String[] argv) {
Scanner scan = new Scanner(System.in);
boolean Again = true;
char YN;
double Upper, Lower, Height, Area;
System.out.println("Calculate a trapezoid\'s area");
while (Again == true){
Upper = Lower = Height = Area = 0;
System.out.print("Input the trapezoid\'s upper base(cm):");
Upper = scan.nextDouble(); //The upper base of the trapezoid
System.out.print("\r\nInput the trapezoid\'s lower base(cm):");
Lower = scan.nextDouble(); //The lower base of the trapezoid
System.out.print("\r\nInput the trapezoid\'s height(cm):");
Height = scan.nextDouble(); //The height of the trapezoid
Area = (Upper + Lower) /2 *Height; //The area of the trapezoid
System.out.println("\r\nThe area of the trapezoid is" + Area + "cm2");
System.out.print("Do you want to calculate another trapezoid\'s area?
Input Y or N.");
YN = scan.nextChar();
if (YN == 'N'){
Again = false;
}
}
}
}