Computer Science, asked by rockonhuntersingh, 1 year ago

write a program to test whether 3 given side form a triangle or not.

Answers

Answered by MohammedRahil
0
The sum of the lengths of any two sides of a triangle is greater than the length of the third side. If you take the three sides of a triangleand add them in pairs, the sum is greater than (not equal to) the third side.

This theorem simply states that the sum of two sides of a triangle must be greater than the third side. If this is true for all three combinations, then you will have a valid triangle. You'll have to go through these combinations one by one to make sure that the triangle is possible.

Condition on the sides. The triangle inequality states that the sum of the lengths of any two sides of a triangle must be greater than or equal to the length of the third side. That sum can equal the length of the third side only in the case of a degenerate triangle, one with collinear vertices.

MohammedRahil: give me brainliest mark
rockonhuntersingh: plz give the full program
MohammedRahil: ok
rockonhuntersingh: completed or not???
MohammedRahil: completed
rockonhuntersingh: plz give then
rockonhuntersingh: yet not received??
Answered by stylishtamilachee
0

Answer:

import.java.util.Scanner ;

public class TriangleTest

{

public static boolean CanMake(int s1, int s2, int s3)

{

boolean result;

if (s1 + s2 > s3 && s2 + s3 > s1 && s3+s1>s2)

result = true;

else

result = false;

return result;

}

public static void main (String[ ] arts)

{

Scanner sc = new Scanner (System.in) ;

int side 1, side 2, side 3 ;

System.out.println("Enter 3 sides") ;

Side 1 = sc.nextInt( ) ;

Side 2 = sc.nextInt( ) ;

Side 3 = sc.nextInt( ) ;

if (CanMake (side1, side2, side 3) == true)

System.out.println("Given 3 sides will make a triangle");

else

System.out.println("Given 3 sides cannot make a triangle");

}

}

Example Output :

Enter 3 sides

10 14 12

Given 3 sides will make a triangle

Similar questions