veronikaaa86

Lab06. TriangleArea

Feb 1st, 2018
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.61 KB | None | 0 0
  1. import java.text.DecimalFormat;
  2. import java.util.Scanner;
  3.  
  4. public class Lab06_TriangleArea {
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.         DecimalFormat df = new DecimalFormat("#.########");
  8.  
  9.         double width = Double.parseDouble(scanner.nextLine());
  10.         double height = Double.parseDouble(scanner.nextLine());
  11.  
  12.         double area = calculateArea(width, height);
  13.         System.out.printf("%s", df.format(area));
  14.     }
  15.  
  16.     public static double calculateArea(double width, double height) {
  17.         return (width * height) / 2;
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment