Eval 9

mail@pastecode.io avatar
unknown
java
2 months ago
722 B
16
Indexable
Never
public class Main {

    public static boolean isTriangle(int a, int b, int c) {
        if (a + b > c && a + c > b && b + c > a) {
            return true;
        } else {
            return false;
        }
    }

    public static void triArea(int a, int b, int c) {
        if (isTriangle(a, b, c)) {
            double s = (a + b + c) / 2.0;
            double area = Math.sqrt(s * (s - a) * (s - b) * (s - c));
            System.out.println(area);
        } else {
            System.out.println("Can't form triangle");
        }
    }

    public static void main(String[] args) {
        boolean res = isTriangle(3,2,1);
        System.out.println(res);
        triArea(3,2,1);
    }
}
Leave a Comment