Advertisement
veronikaaa86

Lab 06

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