Question
Rewrite the program segment 14-20 such that the compound conditions are replaced by nested if-then-else statements. Compare the cyclomatic complexity of your program with that
Rewrite the program segment 14-20 such that the compound conditions are replaced by nested if-then-else statements. Compare the cyclomatic complexity of your program with that of the existing version.
14. If (a = b) AND (b = c)
15. Then Output ("Equilateral")
16. Else If (a != b) AND (a != c) AND (b != c)
17. Then Output ("Scalene")
18. Else Output ("Isosceles")
19. EndIf
20. EndIf
Also, look at the original program segments 14-20. What happens with a test case (e.g., a = 3, b = 4, c = 3) in which a = c? The condition in line 14 uses the transitivity of equality to eliminate the a = c condition. Is this a problem?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started