求,关于用java判断输入3个数组成什么三角形
展开全部
package com.pzr.demo;
import java.util.Scanner;
public class Demo3 {
public static String T(double a, double b, double c) {
double tem = Math.max(a, b);
if (tem > c) {
if (tem == a) {
a = c;
} else {
b = c;
}
c = tem;
}
if (!(a + b > c && Math.abs(a - b) < c)) {
return "无法构成三角形";
} else if (a == b && a == c && b == c) {
return "等边三角形";
}else if (a == b || a == c || b == c) {
return "等腰三角形";
} else if (a * a + b * b == c * c) {
return "直角三角形";
} else if (a * a + b * b < c * c) {
return "锐角三角形";
} else
return "钝角三角形";
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入三角形的三个边:");
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
System.out.println(Demo3.T(a, b, c));
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询