Advertisement
IRusev

Problem 2. Triangle Area

Sep 9th, 2014
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class TriangleArea {
  5.  
  6. public static void main(String[] args) {
  7.  
  8. Scanner input = new Scanner(System.in);
  9.  
  10. double firstX = input.nextDouble();
  11. double firstY = input.nextDouble();
  12.  
  13. double secondX = input.nextDouble();
  14. double secondY = input.nextDouble();
  15.  
  16. double thirdX = input.nextDouble();
  17. double thirdY = input.nextDouble();
  18.  
  19. double area = (firstX*(secondY-thirdY) + secondX*(thirdY-firstY) + thirdX*(firstY-secondY))/2;
  20. System.out.println(Math.abs(area));
  21. input.close();
  22. }
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement