三角形的判断
来源:互联网 发布:现货软件哪个好 编辑:程序博客网 时间:2024/05/16 12:32
这次的编写也是有很多的不懂,还出现了类名上的错误,找了同学才弄明白
import java.util.Scanner;class Triangle1 {public boolean isTriangle(int a ,int b, int c ){boolean flag= false;if (a+b>c&&a+c>b&&c+b>a){flag =true;}return flag;}}class Triangle2{public String shape (int a ,int b, int c){String shape;//常量的声明if (a*a==b*b+c*c||b*b==a*a+c*c||c*c==a*a+b*b)//条件的判断{shape="直角三角形.";}else if (a*a>b*b+c*c||b*b>a*a+c*c||c*c>a*a+b*b){shape="钝角三角形.";}else if (a==b&&b==c){shape="等边三角形";}else {shape="锐角三角形";}return shape;}}class TriangleTest{public static void main(String[]args){Scanner input =new Scanner(System.in);//声明扫描仪Triangle1 t=new Triangle1();//对象的创建Triangle2 t=new Triangle2();int a,b,c;String n;do{System.out.print("请输入第一条边:");a =input.nextInt();System.out.print("请输入第二条边:");b =input.nextInt();System.out.print("请输入第三条边:");c =input.nextInt();if (t.isTriangle(a,b,c)) {System.out.println("这是一个"+t.shape(a,b,c)); }else{System.out.println("这不能构成三角形!");}System.out.print("是否继续?y/n");n=input.next();}while (n.equals("y"));System.out.print("程序结束!");}}
0 0
- 判断三角形的形状
- 判断三角形的形状
- 三角形的判断
- 判断三角形的形状
- 判断三角形的性质
- 判断三角形的性质
- 三角形的判断
- 三角形的判断
- 三角形的判断类型
- 三角形类型的判断
- 三角形的判断
- 判断三角形的类型
- 判断三角形的形状
- 判断三角形的类型
- 三角形的判断
- 判断三角形的类型
- 三角形的判断
- 三角形的判断
- 10 mins 搞懂“倒排索引”
- 4.检测到 Mac 文件格式: 请将源文件转换为 DOS 格式或 UNIX 格式
- NKOI 3515 玻璃球
- 用 Qt 的 QAudioOutput 类播放 WAV 音频文件
- 长时间不发博客就会被封?
- 三角形的判断
- POJ-3450 Corporate Identity(KMP/后缀数组)
- 学习Java分为几个阶段,分别是什么?
- NEUOJ Problem48
- Gson是如何记录泛型信息的
- 11g rac grid安装 网络通不过 INS-41112
- 位运算
- 整理系列-20161117-nfdump-nfsen_cacti_nagios(我只是大自然的搬运工)
- 一、设置textView的行间距