发布网友 发布时间:2022-04-23 15:53
共1个回答
热心网友 时间:2023-07-16 08:30
public class Sanjiaoxin{
public static void main(String args[]) {
System.out.println("请输入三个数:");
Scanner scanner = new Scanner(System.in);
int a = scanner.nextByte();
int b = scanner.nextByte();
int c = scanner.nextByte();
float s = (a+b+c)/2f;
float S = (float)Math.sqrt(s*(s-a)*(s-b)*(s-c));
float D = a+b+c;
if(a+b>c && a+c>b && b+c>a) {
System.out.println("三角形的面积为:"+S);
System.out.println("三角形的周长为:"+D);
}
else {
System.out.println("三角形不成立");
}
}
}