Question: Write me a function that receives three integer inputs for the lengths of the sides of a triangle and returns one of four values to determine the triangle type (1=scalene, 2=isosceles, 3=equilateral, 4=error). Generate test cases for the function assuming another developer coded the function
Solution: Check for the 3 conditions to determine the triangle
1) if (a+b<=c||a+c<=b||b+c<=a)
not a triangle
2) if (a=b=c)
equilateral
3) if(a==b||b==c||a==c)
isosceles
else
scalene triangle
Test Cases
Test Input Expected Result
- ve element (-4,2,3) Error!
sum of 2 = to the 3rd (3,4,7) Error!
sum of 2 less than third (3,3,9) Error definitely
all three same (5,5,5) Equilateral
special characters (*,5,5) Error
Two sides equal (4,5,5) Isosceles
More than 3 elements (3,4,5,6) Error
No sides Matching (3,4,5) Scalene