- package test;
- import java.util.Scanner;
- public class JPA02 {
- static Scanner keyboard = new Scanner(System.in);
- public static void main(String[] args) {
-
- // TODO 自動產生的方法 Stub
- test();
- test();
- test();
- test();
- }
- static void test() {
- System.out.print("請輸入三個整數 : ");
- int a=keyboard.nextInt();
- int b=keyboard.nextInt();
- int c=keyboard.nextInt();
-
- if(a+b>c && a+c>b && b+c>a)
- {
- if(a*a+b*b==c*c ||a*a+c*c==b*b ||b*b+c*c==a*a)
- {
- System.out.println("直角三角形");
- }
- else if(a*a+b*b<c*c ||a*a+c*c<b*b ||b*b+c*c<a*a)
- {
- System.out.println("鈍角三角形");
- }
- else if(a*a+b*b>c*c ||a*a+c*c>b*b ||b*b+c*c>a*a)
- {
- System.out.println("銳角三角形");
- }
-
- }
- else{
- System.out.println("不可構成三角形");
- }
- }
- }
複製代碼 |