Write a class called Triangle that represents a triangle A t
Solution
As per the given guidelines, please find the Class triangle with the three double precision variable and constructor for the initialization. All the required functions have been added as per their required functionality. For the area function, have used the heron\'s formula s(s-a)(s-b)(s-c). Kindly please import the required data.
public class Triangle {
private double a;
private double b;
private double c;
public Triangle(double a, double b, double c) {
this.a = a;
this.b = b;
this.c = c;
}
public boolean isTriangle() {
if (((a + b) > c) && ((b + c) > a) && ((c + a) > b))
return true;
return false;
}
public boolean isScalene() {
if ((a != b) && (a != c) && (b != c)) {
return true;
}
return false;
}
public boolean isEquilateral() {
if ((a == b) && (b == c)) {
return true;
}
return false;
}
public boolean isRight() {
if (Math.pow(a, 2) == (Math.pow(b, 2) + Math.pow(c, 2))) {
return true;
} else if (Math.pow(b, 2) == (Math.pow(a, 2) + Math.pow(c, 2))) {
return true;
} else if (Math.pow(c, 2) == (Math.pow(a, 2) + Math.pow(b, 2))) {
return true;
}
return false;
}
public boolean isIsosceles() {
if ((a == b) && (b == c)) {
return true;
} else if ((a == b) || (b == c) || (c == a)) {
return true;
}
return false;
}
public double area() {
double s = (a + b + c) / 2;
return Math.sqrt(s * (s - a) * (s - b) * (s - c));
}
@Override
public String toString() {
return \"Triangle [a=\" + a + \", b=\" + b + \", c=\" + c + \", isTriangle()=\"
+ isTriangle() + \", isScalene()=\" + isScalene()
+ \", isEquilateral()=\" + isEquilateral() + \", isRight()=\"
+ isRight() + \", isIsosceles()=\" + isIsosceles() + \", area()=\"
+ area() + \"]\";
}
}

