Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javaSyntaxix;
- import java.util.Scanner;
- public class TriangleArea {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- String firstPoint = sc.nextLine();
- String firstArr[] = firstPoint.split(" ");
- int ax = Integer.parseInt(firstArr[0]);
- int ay = Integer.parseInt(firstArr[1]);
- String secondPoint = sc.nextLine();
- String secondArr[] = secondPoint.split(" ");
- int bx = Integer.parseInt(secondArr[0]);
- int by = Integer.parseInt(secondArr[1]);
- String thirdPoint = sc.nextLine();
- String thirdArr[] = thirdPoint.split(" ");
- int cx = Integer.parseInt(thirdArr[0]);
- int cy = Integer.parseInt(thirdArr[1]);
- int area = (ax*(by-cy) + bx*(cy-ay) + cx*(ay-by))/2;
- if(area>=0) System.out.println(area);
- else System.out.println(area*-1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement