Exam CTAL-TTA Topic 1 Question 100 Discussion
Actual exam question for ISTQB's CTAL-TTA exam
Question #: 100
Topic #: 1
Question #: 100
Topic #: 1
How many test cases need to be designed to achieve 100% decision coverage in the following piece of pseudo-code which applies discount rates to hotel room bookings?
Read (Loyalty_level)
Read (Room_price)
IF (Room_price > 200)
IF (Loyalty_level = Platinum)
Discount_factor = 80%
ELSE
IF (Loyalty_level = Gold)
Discount_factor = 85%
ELSE
Discount_factor = 95%
ENDIF
ENDIF
ELSE
IF (Room_price > 150)
IF (Loyalty_level = Platinum)
Discount_factor = 85%
ELSE
Discount_factor = 95%
ENDIF
ELSE
Discount_factor = 100%
ENDIF
ENDIF
Room_price = Room_price * Discount_factor
IF (Discount_factor < 100%)
Show message "Congratulations - you have received a discount!"
ENDIF
Read (Loyalty_level)
Read (Room_price)
IF (Room_price > 200)
IF (Loyalty_level = Platinum)
Discount_factor = 80%
ELSE
IF (Loyalty_level = Gold)
Discount_factor = 85%
ELSE
Discount_factor = 95%
ENDIF
ENDIF
ELSE
IF (Room_price > 150)
IF (Loyalty_level = Platinum)
Discount_factor = 85%
ELSE
Discount_factor = 95%
ENDIF
ELSE
Discount_factor = 100%
ENDIF
ENDIF
Room_price = Room_price * Discount_factor
IF (Discount_factor < 100%)
Show message "Congratulations - you have received a discount!"
ENDIF
Suggested Answer: A Vote an answer
To achieve 100% decision coverage, we need to ensure that every decision (if statement) in the code has been tested for both true and false outcomes. Let's analyze the code and count the decisions:
* IF (Room_price > 200)
* IF (Loyalty_level = Platinum) inside Room_price > 200
* ELSE within the same decision above
* IF (Loyalty_level = Gold) inside the ELSE of decision 2
* IF (Room_price > 150)
* IF (Loyalty_level = Platinum) inside Room_price > 150
* ELSE within the same decision above
* IF (Discount_factor < 100%)
To cover all these decisions, we need test cases for each possible combination:
* Room_price > 200 and Loyalty_level = Platinum.
* Room_price > 200 and Loyalty_level = Gold.
* Room_price > 200 and Loyalty_level not Platinum or Gold.
* Room_price <= 200 and Room_price > 150, and Loyalty_level = Platinum.
* Room_price <= 200 and Room_price > 150, and Loyalty_level not Platinum.
* Room_price <= 150.
From these scenarios, we can see that the minimum number of test cases required to achieve 100% decision coverage is four:
* Test with Room_price > 200 and Loyalty_level = Platinum (tests decision 1 true, 2 true, and 8 true).
* Test with Room_price > 200 and Loyalty_level = Gold (tests decision 1 true, 2 false, 4 true, and 8 true).
* Test with Room_price > 200 and Loyalty_level not Platinum or Gold (tests decision 1 true, 2 false, 4 false, and 8 true).
* Test with Room_price <= 200 and Room_price > 150, and Loyalty_level = Platinum (tests decision 1 false, 5 true, 6 true, and 8 true).
* Test with Room_price <= 200 and Room_price > 150, and Loyalty_level not Platinum (tests decision 1 false, 5 true, 6 false, and 8 true).
* Test with Room_price <= 150 (tests decision 1 false, 5 false, and 8 false).
Given that these six cases test all branches, four test cases are required to ensure that all decisions are covered at least once.
Therefore, the correct answer is A. 4.
* IF (Room_price > 200)
* IF (Loyalty_level = Platinum) inside Room_price > 200
* ELSE within the same decision above
* IF (Loyalty_level = Gold) inside the ELSE of decision 2
* IF (Room_price > 150)
* IF (Loyalty_level = Platinum) inside Room_price > 150
* ELSE within the same decision above
* IF (Discount_factor < 100%)
To cover all these decisions, we need test cases for each possible combination:
* Room_price > 200 and Loyalty_level = Platinum.
* Room_price > 200 and Loyalty_level = Gold.
* Room_price > 200 and Loyalty_level not Platinum or Gold.
* Room_price <= 200 and Room_price > 150, and Loyalty_level = Platinum.
* Room_price <= 200 and Room_price > 150, and Loyalty_level not Platinum.
* Room_price <= 150.
From these scenarios, we can see that the minimum number of test cases required to achieve 100% decision coverage is four:
* Test with Room_price > 200 and Loyalty_level = Platinum (tests decision 1 true, 2 true, and 8 true).
* Test with Room_price > 200 and Loyalty_level = Gold (tests decision 1 true, 2 false, 4 true, and 8 true).
* Test with Room_price > 200 and Loyalty_level not Platinum or Gold (tests decision 1 true, 2 false, 4 false, and 8 true).
* Test with Room_price <= 200 and Room_price > 150, and Loyalty_level = Platinum (tests decision 1 false, 5 true, 6 true, and 8 true).
* Test with Room_price <= 200 and Room_price > 150, and Loyalty_level not Platinum (tests decision 1 false, 5 true, 6 false, and 8 true).
* Test with Room_price <= 150 (tests decision 1 false, 5 false, and 8 false).
Given that these six cases test all branches, four test cases are required to ensure that all decisions are covered at least once.
Therefore, the correct answer is A. 4.
by Ophelia at Nov 10, 2025, 07:44 AM
0
0
0
10
Comments
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Report Comment
Commenting
You can sign-up / login (it's free).