Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import javax.lang.model.util.ElementScanner6;
- class Main {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- double x1 = Double.parseDouble(scan.nextLine());
- double y1 = Double.parseDouble(scan.nextLine());
- double x2 = Double.parseDouble(scan.nextLine());
- double y2 = Double.parseDouble(scan.nextLine());
- double x3 = Double.parseDouble(scan.nextLine());
- double y3 = Double.parseDouble(scan.nextLine());
- if (x1*(y2-y3)+ x2*(y3-y1) + x3*(y1 - y2) == 0){
- System.out.println("Three points on one line!");
- }else {
- double a = Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
- double b = Math.sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1));
- double c = Math.sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3));
- double p = (a+b+c) /2;
- double s = Math.sqrt(p*(p-a)*(p-b)*(p-c));
- System.out.printf("s = %2f", s);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement