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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!