Consider the following triangle classication system, originally used by Myers [1
ID: 3735726 • Letter: C
Question
Consider the following triangle classication system, originally used by Myers [16]: The system reads in three positive values from the standard input. The three values A, B, and C are interpreted as representing the lengths of the sides of a triangle. The system then prints a message on the standard output saying whether the triangle is scalene, isosceles, equilateral, or right angled if a triangle can be formed. Answer the following questions for the above program: Part a: What is the input domain of the system? Part b: What are the input conditions? Part c: Identify the equivalence classes for the system? Part d: Identify test cases to cover the identied ECs?
Explanation / Answer
Please find the answers for the question answer parts :
Part a:
What is the input domain of the system?
Input domain of the system is the inputs passed to the program. i.e Three side lengths of the Triangle under test.
Example : TriangleClassification (7, 9, 9);
Part b:
What are the input conditions?
Input conditions are valid inputs and invalid inputs. For length of triangle side input, we require a positive side length. A valid input to the program returns a valid program output. An invalid input is an input the program responds with an error.
Example: Valid Input:
new TriangleClassification (7, 9, 9);
Invalid input:
new TriangleClassification (-7, -9, -9);
Part c:
Identify the equivalence classes for the system?
Equivalence classes are test case execution minimization techniques. An equivalence class is a set of inputs that the program treats as identical.
Equivalence classes for the system can be identified as below:
EqClass_Scalene - to test the Scalene triangle type
EqClass_RightAngled - to test the Right Angled triangle type
EqClass_Isosceles - to test the Isosceles Triangle
EqClass_Equilateral - to test the Equilateral Triangle
EqClass_NotTriangled
EqClass_Invalid1 to test Invalid side length
EqClass_Invalid2
EqClass_Invalid3;
Part d:
Identify test cases to cover the identied ECs?
TestInputs Outputs
TriangleClassification(3, 5, 7); Scalene Triangle
TriangleClassification(3, 4,5 ); Right Angled Triangle
TriangleClassification(3, 3, 3); Equilateral Triangle
TriangleClassification(3, 4, 4); Isosceles Triangle
TriangleClassification(2, 3, 9); Check Input.Do not form a triangle
TriangleClassification(-3, 4, 4); ERROR : negative sides
TriangleClassification(3, -4, 4); ERROR : negative sides
TriangleClassification(3, 4, -4); ERROR : negative sides
Sample Program:
/*