This question already has an answer here:
- Error: 'else' without 'if' 3 answers
int numComparisons, comparisons, a, b, c, scalene, equilateral, isoceles, triangle;
Scanner scan = new Scanner(System.in);
System.out.print("Enter 3 positive integer lengths for the sides of a triangle: ");
a = scan.nextInt();
b = scan.nextInt();
c = scan.nextInt();
System.out.print("The input lengths are: " + a + ", " + b + ", and" + c);
if (a+b>c&&b+c>a&&a+c>b);
System.out.println("The triangle with sides " + a + "," + b + ", and" + c + " is Scalene.");
if (a==b&&b==c)
System.out.println("The triangle with sides " + a + "," + b + ", and" + c + " is Equilateral");
else // (a==b) || (a==c) || (b==c)
System.out.println("The triangle with sides " + a + "," + b + ", and" + c + " is Isoceles");
else System.out.println("There is no triangle with sides " + a + "," + b + ", and" + c);
Aucun commentaire:
Enregistrer un commentaire