Sou iniciante em Java e autodidata. Vi o enunciado de um exercício na Internet pedindo para criar um programa para comparação de tipos de triângulos e fiz o código abaixo. Usei o Netbeans e Notepad++. Está funcionando, mas não tenho certeza se é o correto a se fazer. Agradeço opiniões e sugestões.
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
double v1 = Double.parseDouble(txtv1.getText());
double v2 = Double.parseDouble(txtv2.getText());
double v3 = Double.parseDouble(txtv3.getText());
if ((v1<v2+v3) && (v2<v1+v3) && (v3<v1+v2)){
if ((v1==v2) && (v2==v3)){
txtfinal.setText("TRIANGULO EQUILATERO");
txtfinal1.setText("Três lados são iguais");
}
else{
if ((v1==v2) || (v1==v3) || (v2==v3)){
txtfinal.setText("TRIANGULO ISOSCELES");
txtfinal1.setText("Dois lados são iguais");}
else
{
txtfinal.setText("TRIANGULO ESCALENO");
txtfinal1.setText("Três lados são diferentes");
}
}
}
else{
txtfinal.setText("VALORES NÃO FORMAM UM TRIANGULO");
txtfinal1.setText("DIGITE OUTROS VALORES");
}
}