I have this program that I need help with. Basically its a program where a user is prompted to enter the length of all three sides of a triangle and the program calculates the area by herons formula and can tell if the triangle is equilateral or Pythagorean. I am having trouble entering a formula to where all three enter sides cant possibly be a triangle. Here is my Program. I need help where the '?' is stated.
import java.util.Scanner;
public class Triangle {
public static void main(String[] args){
double a;
double b;
double c;
double s;
double x;
double area;
Scanner input = new Scanner(System.in);
System.out.println("Welcome to the Triangle Calculation Program");
System.out.print ("Enter length of side one => ");
a = input.nextDouble();
System.out.print ("Enter length of side two => ");
b = input.nextDouble();
System.out.print ("Enter length of side three => ");
c = input.nextDouble();
System.out.println("Your triangle has an area of " + getArea(a,b,c));
if ( (a == b) && (b == c) ) {
System.out.println("This was a Equilateral triangle");
}
else if ( ( a*a + b*b == c*c ) || (b*b + c*c == a*a) || (c*c + a*a == b*b )) {
System.out.println("This was a Pythagorean triangle");
}
else if ( ( ? ) ) {
System.out.println("Sorry- not a valid triangle");
}
}
public static double getArea(double a, double b, double c) {
double s = (a + b + c)/2.0;
double x = ((s) * (s-a) * (s-b) * (s-c));
double area = Math.sqrt(x);
return area;
}
}