返回列表 發帖
本帖最後由 黃博鴻 於 2013-6-29 16:52 編輯
  1. public class tqc208
  2. {
  3.      public static void main(String args[])
  4.      {
  5.          try
  6.          {
  7.             if(args.length==3)
  8.             {
  9.                double a=Double.parseDouble(args[0]);
  10.                double b=Double.parseDouble(args[1]);
  11.                double c=Double.parseDouble(args[2]);
  12.                tell(a,b,c);
  13.             }else
  14.             {
  15.                System.out.println("參數數目錯誤:三角形的邊長應有三個參數!");
  16.             }
  17.          }catch(Exception e)
  18.          {
  19.              System.out.println("參數數目錯誤:三角形的邊長應有三個參數!");
  20.          }
  21.      }
  22.      public static void tell(double a, double b, double c)
  23.      {
  24.          if(a+b>c && a*b*c!=0)
  25.          {
  26.              if(a==b && b==c)
  27.                  System.out.println("您所輸入的是一個等邊三角形的邊長資料!");
  28.              else if(a*a+b*b==c*c && a==b)
  29.                  System.out.println("您所輸入的是一個等腰直角三角形的邊長資料!");
  30.              else if(a==b)
  31.                  System.out.println("您所輸入的是一個等腰三角形的邊長資料!");
  32.              else if(a*a+b*b==c*c)
  33.                  System.out.println("您所輸入的是一個直角三角形的邊長資料!");
  34.              else if(a*a+b*b>c*c)
  35.                  System.out.println("您所輸入的是一個鈍角三角形的邊長資料!");
  36.              else
  37.                  System.out.println("您所輸入的是一個銳角三角形的邊長資料!");
  38.          }else
  39.          {
  40.                  System.out.println("您所輸入的並非一個三角形的邊長資料!");
  41.          }
  42.      }
  43. }
複製代碼

TOP

返回列表