/*
* 試撰寫一程式,由程式中宣告並設定三個整數的初值,判斷這三個整數是否能構成三
角形的三個邊長(註: 三角形兩邊長之和必須大於第三邊)。
*/
import java.util.Scanner;
public class P5_2_14 {
public static void main(String[] args) {
System.out.println("請輸入三角形的三個邊長");
System.out.println("第1個邊長");
Scanner s1=new Scanner(System.in);
int x=s1.nextInt();
System.out.println("第2個邊長");
Scanner s2=new Scanner(System.in);
int y=s2.nextInt();
System.out.println("第3個邊長");
Scanner s3=new Scanner(System.in);
int z=s3.nextInt();
if((x+y>z)&&(x+z>y)&&(y+z>x)){
System.out.println("能構成三角形");
}else{
System.out.println("不能構成三角形");
}
}

}

/*

第1個邊長
50
第2個邊長
60
第3個邊長
70
能構成三角形

*/

arrow
arrow
    文章標籤
    java
    全站熱搜

    goodlucky23 發表在 痞客邦 留言(0) 人氣()