borkins

Exam Jan-2016 - 01. Triangle Area

May 11th, 2017
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 KB | None | 0 0
  1. /**
  2.  * Project: Exam_101_January_2016 - created by borkins on 2017-05-03.
  3.  */
  4.  
  5. import java.text.DecimalFormat;
  6. import java.util.Scanner;
  7.  
  8. public class _01_TriangleArea
  9. {
  10.     public static void main(String[] args)
  11.     {
  12.         Scanner console = new Scanner(System.in);
  13.         DecimalFormat df = new DecimalFormat("0.##");
  14.        
  15.         int x1 = Integer.parseInt(console.nextLine());
  16.         int y1 = Integer.parseInt(console.nextLine());
  17.         int x2 = Integer.parseInt(console.nextLine());
  18.         int y2 = Integer.parseInt(console.nextLine());
  19.         int x3 = Integer.parseInt(console.nextLine());
  20.         int y3 = Integer.parseInt(console.nextLine());
  21.        
  22.         double base = Math.abs(x2 - x3);
  23.         double height = Math.abs(y1 - y3);
  24.         double area = base * height / 2;
  25.        
  26.         System.out.println(df.format(area));
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment