ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

验证三角形的有效性

2022-05-13 12:33:23  阅读:41  来源: 互联网

标签:验证 System edge1 edge2 edge3 input 三角形 有效性 nextDouble


import java.util.*;
import javax.swing.*;  
  class Main {
    public static void main(String[] args){
      Scanner input = new Scanner(System.in);
      System.out.print("Enter three edges: ");
      double edge1 = input.nextDouble();
      double edge2 = input.nextDouble();
      double edge3 = input.nextDouble();

      boolean flag = (edge1 + edge2) > edge3 && (edge1 + edge3) > edge2 && (edge3 + edge2) > edge1;

      System.out.println("Can edges " + edge1 + ", " + edge2 + ", and " + edge3 + " form a triangle? " 
                         + flag);
      
    }
  }

标签:验证,System,edge1,edge2,edge3,input,三角形,有效性,nextDouble
来源: https://www.cnblogs.com/doudou-20123/p/16266262.html

专注分享技术,共同学习,共同进步。侵权联系[admin#icode9.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有