SHARE
TWEET

Triangle Area

16120 Dec 8th, 2019 123 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package areaoftriangle;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class trianglearea {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner sc = new Scanner(System.in);
  9.     int x1 = Integer.parseInt(sc.nextLine());
  10.     int y1 = Integer.parseInt(sc.nextLine());
  11.     int x2 = Integer.parseInt(sc.nextLine());
  12.     int y2 = Integer.parseInt(sc.nextLine());
  13.     int x3 = Integer.parseInt(sc.nextLine());
  14.     int y3 = Integer.parseInt(sc.nextLine());
  15.  
  16.     int a = Math.abs(x2 - x3);
  17.     int h = Math.abs(y2 - y1);
  18.    
  19.     double s = (double)a * h / 2;
  20.     System.out.println(s);
  21.  
  22.     }
  23.  
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top