Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Triangle {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- int xA = input.nextInt();
- int yA = input.nextInt();
- int xB = input.nextInt();
- int yB = input.nextInt();
- int xC = input.nextInt();
- int yC = input.nextInt();
- double distAB = getDistance(xA, yA, xB, yB);
- double distAC = getDistance(xA, yA, xC, yC);
- double distBC = getDistance(xB, yB, xC, yC);
- if( distAB + distAC > distBC &&
- distAC + distBC > distAB &&
- distBC + distAB > distAC){
- System.out.println("Yes");
- System.out.printf("%.2f", getArea(distAB, distAC, distBC));
- }else {
- System.out.println("No");
- System.out.printf("%.2f", distAB);
- }
- }
- private static double getDistance(int xA, int yA, int xB, int yB) {
- double dist = Math.sqrt((double)Math.pow((xB - xA), 2) + (double)Math.pow((yB - yA), 2));
- return dist;
- }
- private static double getArea(double distAB, double distAC, double distBC) {
- double p = (distAB + distAC + distBC) / 2;
- double area = Math.sqrt(p * (p - distAB) * (p - distAC) * (p - distBC));
- return area;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement