wap in java to test whether 3 given sides form a triangle or not
Answers
Answered by
2
Hey there! ☺☻☺
Program to test whether 3 given sides form a triangle or not.
isValidTriangle(int a, int b, int c)
{
if(((b+c)>a)&&((a+b)>c)&&((a+c)>b))
{
return true
}else{
return false
}
Hope It Helps You! ☺☻☺
Program to test whether 3 given sides form a triangle or not.
isValidTriangle(int a, int b, int c)
{
if(((b+c)>a)&&((a+b)>c)&&((a+c)>b))
{
return true
}else{
return false
}
Hope It Helps You! ☺☻☺
Anonymous:
nice
Answered by
0
Hey there
————————————————————————————
import java.io.*;
import java.util.*;
class triangle_validity
{
int l1, l2,l3;
public triangle_validity(int a, int b, int c)
{
l1 = a;
l2 = b;
l3 = c;
}
public void check_validity()
{
if ((l1 + l2) > l3)
{
if((l1 + l3) > l2)
{
if(l2 + l3 > l1)
{
System.out.println("\nThe Triangle is a Valid Triangle\n\n");
}
else
{
}
}
}
class Demo
{
public static void main(String args[])
{
int a, b, c;
System.out.println("\nLength of Third Side: \t");
c = sc.nextInt();
triangle_validity obj1 = new
triangle_validity(a,b,c);
obj1.check_validity();
}
}
————————————————————————————
import java.io.*;
import java.util.*;
class triangle_validity
{
int l1, l2,l3;
public triangle_validity(int a, int b, int c)
{
l1 = a;
l2 = b;
l3 = c;
}
public void check_validity()
{
if ((l1 + l2) > l3)
{
if((l1 + l3) > l2)
{
if(l2 + l3 > l1)
{
System.out.println("\nThe Triangle is a Valid Triangle\n\n");
}
else
{
}
}
}
class Demo
{
public static void main(String args[])
{
int a, b, c;
System.out.println("\nLength of Third Side: \t");
c = sc.nextInt();
triangle_validity obj1 = new
triangle_validity(a,b,c);
obj1.check_validity();
}
}
Similar questions