du4ko

ExamPrepOne

May 19th, 2014
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.00 KB | None | 0 0
  1. package ExamPreparation;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class CourtesianTabletwo {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner scan = new Scanner(System.in);
  9.         double Ax = scan.nextDouble();
  10.         double Ay = scan.nextDouble();
  11.         double Bx = scan.nextDouble();
  12.         double By = scan.nextDouble();
  13.         double Cx = scan.nextDouble();
  14.         double Cy = scan.nextDouble();
  15.        
  16.         double sumAB =Math.sqrt((Bx - Ax)*(Bx - Ax) + (By - Ay)*(By - Ay));
  17.         double sumBC = Math.sqrt((Cx - Bx)*(Cx - Bx) + (Cy - By)*(Cy - By));
  18.         double sumAC = Math.sqrt((Cx - Ax)*(Cx - Ax) + (Cy - Ay)*(Cy - Ay));
  19.         if(sumAB + sumBC > sumAC && sumAC + sumBC > sumAB && sumAB + sumAC > sumBC ){
  20.             double p = (sumAB + sumBC + sumAC)/2;
  21.             double Area = Math.sqrt(p*(p-sumAB)*(p-sumBC)*(p-sumAC));
  22.             System.out.println("Yes");
  23.             System.out.printf("%.2f%n",Area);
  24.         }
  25.         else {
  26.             System.out.println("No");
  27.             System.out.printf("%.2f%n", sumAB);
  28.         }
  29.          
  30.     }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment