Write Static Method Aretriangular Takes Three Double Values Arguments Returns True Could S Q37276815

Write a static method areTriangular() that takes three doublevalues as arguments and returns true if they could be the sides ofa triangle (none of them is greater than or equal to the sum of theother two). In Java language please


Answer


ANSWER:-

import java.util.*;

public class TriangleSides
{
   public static boolean areTriangular(double a,doubleb,double c)
   {
       if((a+b<c) || (a+c<b) ||(b+c<a))
       return false;
       else
       return true;
   }
   public static void main (String[] args)
   {
       double a,b,c;
       Scanner sc=newScanner(System.in);
       System.out.println(“Enter the threevalues : “);
       a=sc.nextDouble();
       b=sc.nextDouble();
       c=sc.nextDouble();
       if(areTriangular(a,b,c))
       System.out.println(“these are sidesof triangle “);
      

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.