Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class _02_TriangleArea {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int aX = scan.nextInt();
- int aY = scan.nextInt();
- int bX = scan.nextInt();
- int bY = scan.nextInt();
- int cX = scan.nextInt();
- int cY = scan.nextInt();
- int triangleArea = Math.abs((aX * (bY - cY) + bX * (cY - aY) + cX * (aY - bY)) / 2);
- if (triangleArea != 0) {
- System.out.printf("The area of the triangle is: %d", triangleArea);
- }
- else {
- System.out.println("All points lie in a straight line and do not form a triangle");
- System.out.println("0");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement