其他分享
首页 > 其他分享> > 验证三角形的有效性

验证三角形的有效性

作者:互联网

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