JAVA三角形边长定义_Java编译:定义三角形的三条边长a=4,b=8.54,c=4.44;求三角形的周长d...
生活随笔
收集整理的這篇文章主要介紹了
JAVA三角形边长定义_Java编译:定义三角形的三条边长a=4,b=8.54,c=4.44;求三角形的周长d...
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
共回答了20個問題采納率:95%
(package/import/class聲明 省略)
public static void main(String [] arg) {
float a = 4f;
float b = 8.54;
float c = 4.44;
Float d = countPerimeter(a,b,c);
if(d == null) {
System.out.println("This is not a traingle!");
} else {
System.out.println("Traingle's perimeter is :" + d);
}
}
public Float countPerimeter(float a,float b,float c) {
Float perimeter = null;
boolean isTraingle = (( a + b ) > c) && ((b + c) > a) && ((a + c) > b);
if (isTraingle) {
perimeter = a + b + c;
}
return perimeter;
}
1年前
10
總結
以上是生活随笔為你收集整理的JAVA三角形边长定义_Java编译:定义三角形的三条边长a=4,b=8.54,c=4.44;求三角形的周长d...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 敏捷开发之利刃—db4o
- 下一篇: 纯C++编写Win32/X64通用She