TheBulgarianWolf

Trapezoid area

Jan 14th, 2020
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.56 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.         System.out.print("Enter the first side: ");
  8.         double b1 = Double.parseDouble(scanner.nextLine());
  9.         System.out.print("Enter the second side: ");
  10.         double b2 = Double.parseDouble(scanner.nextLine());
  11.         System.out.print("Enter the height: ");
  12.         double h = Double.parseDouble(scanner.nextLine());
  13.         double area = (b1+b2)*h/2.0;
  14.         System.out.println("Trapezoid area: " + area + "cm2");
  15.  
  16.     }
  17. }
Add Comment
Please, Sign In to add comment