I believe that I can be the result of my ordering that is influencing the output, eg if it was 6 8 10 it should show TRIANGLE RETURN but it is showing ACTUALLY TRIANGLE
The code I made is at the end of the statement
Read 3 decimal numbers A, B, and C, and order them in descending order from so that side A represents the largest of the 3 sides. Then determine the type of triangle that these three sides form, based on the following cases, always writing an appropriate message:
If A ≥ B + C, display the message: DO NOT TRIANGLE
If A 2 = B 2 + C 2, display the message: TRIANGLE RETANGLE
if A 2 > B 2 + C 2, present the message: TRIANGULO OBTUSANGULO
if A 2 < B 2 + C 2, display the message: TRIANGLE ACUTANGULO
If all three sides are the same, display the message: TRIANGLE EQUILATERO
If only two sides are the same, display the message: TRIANGULO ISOSCELES
Ex-Entries (A, B, C) Expected Exit 7 5 7
ACTUALLY TRIANGLE TRIANGULO ISOSCELES 6 6 10 TRIANGULO OBTUSANGULO TRIANGULO ISOSCELES6 6 6 ACTUALLY TRIANGLE TRIANGLE EQUILATERAL
5 7 2 DO NOT FORM TRIANGLE
6 8 10 TRIANGLE RETANGULO
Code
public class Ex18 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double a,b,c,maior;
System.out.printf("Digite o valor de A: ");
a=sc.nextDouble();
System.out.printf("Digite o valor de B: ");
b=sc.nextDouble();
System.out.printf("Digite o valor de C: ");
c=sc.nextDouble();
if(a > b){
maior = a;
a = b;
b = maior;
}if(b > c){
maior = b;
b = c;
c = maior;
}
if(a>= c+b){
System.out.println("NAO FORMA TRIANGULO");
}else if((a*a) == (b*b)+(c*c)){
System.out.println("TRIANGULO RETANGULO");
}else if((a*a)>(b*b)+(c*c)){
System.out.println("TRIANGULO OBTUSANGULO");
}else if((a*a)<(b*b)+(c*c)){
System.out.println("TRIANGULO ACUTANGULO");
}
if(a >= b+c){
System.out.println("NAO FORMA TRIANGULO");
}else if( a == b && a == c){
System.out.println("TRIANGULO EQUILATERO");
}else if(a == b || b == c || c == a){
System.out.println("TRIANGULO ISOSCELES");
}else{
System.out.println("");
}
}
}