Advertisement
IvanKrastev

Homework Java Syntax Problem 2 Triangle Area

Jan 26th, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class Problem_2_TriangleArea {
  5.  
  6.     public static void main(String[] args) {
  7.         Scanner scanner= new Scanner(System.in);
  8.         System.out.print("Ax= ");
  9.         int aX= scanner.nextInt();
  10.        
  11.         System.out.print("Ay= ");
  12.         int aY= scanner.nextInt();
  13.        
  14.         System.out.print("Bx= ");
  15.         int bX= scanner.nextInt();
  16.        
  17.         System.out.print("By= ");
  18.         int bY= scanner.nextInt();
  19.        
  20.         System.out.print("Cx= ");
  21.         int cX= scanner.nextInt();
  22.        
  23.         System.out.print("Cy= ");
  24.         int cY= scanner.nextInt();
  25.         int area= (int)Math.abs(((aX * ((bY - cY))) + (bX * ((cY - aY))) + (cX * ((aY - bY)))) / 2);
  26.         if (area > 0 ) {
  27.             System.out.println(area);
  28.         }
  29.         else {
  30.             System.out.println(0);
  31.         }
  32.  
  33.     }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement