Computer Science, asked by bdiu6, 1 year ago

wap in java to test whether 3 given sides form a triangle or not

Answers

Answered by duragpalsingh
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! ☺☻☺

Anonymous: nice
bdiu6: ☺☺
Ashiq11: where is full program?
Ashiq11: u haven't taking input
Ashiq11: in this program
Ashiq11: where is main( ) ?
Ashiq11: the program dont run without main method
Ashiq11: i think theres a need to change some things in program
Ashiq11: like adding a main(), calling the functions you have created
Ashiq11: then only the program would run
Answered by Anonymous
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();

    }

}



Ashiq11: completely copied
Similar questions