例3-3

import java.util.*;
public class Example3_3 {
 public static void main (String args[]){
  Scanner reader=new Scanner(System.in);
  double a=0,b=0,c=0;
  System.out.print("input a:");
  a=reader.nextDouble();
  System.out.print("input b:");
  b=reader.nextDouble();
  System.out.print("input c:");
  c=reader.nextDouble();
  if(a+b>c&&a+c>b&&b+c>a){
   if(a*a==b*b+c*c||b*b==a*a+c*c||c*c==a*a+b*b){
    System.out.printf("%-8.3f%-8.3f%-8.3f make up right triangle",a,b,c);
   }
   else if (a*a<b*b+c*c&&b*b<a*a+c*c&&c*c<a*a+b*b){
    System.out.printf("%-8.3f%-8.3f%-8.3f make up shape triangle",a,b,c);
    
   }
   else{
    System.out.printf("%-8.3f%-8.3f%-8.3f make up obtuse triangle",a,b,c);
   }
  }
  else{
   System.out.printf("%f,%f,%f cannot make up triangle");
  }
 }
}

posted @ 2013-03-16 22:01  崔琪同学  阅读(98)  评论(0编辑  收藏  举报