Bird
0
0

Given this pseudocode for refund calculation:

medium📝 Analysis Q4 of 15
LLD - Design — Hotel Booking System
Given this pseudocode for refund calculation:
if cancellation_time <= allowed_time:
refund = amount * 0.8
else:
refund = 0

What will be the refund if cancellation_time is 3 hours and allowed_time is 5 hours with amount 100?
A20
B0
C80
D100
Step-by-Step Solution
Solution:
  1. Step 1: Compare cancellation_time with allowed_time

    3 hours <= 5 hours is true, so refund applies.
  2. Step 2: Calculate refund amount

    Refund = 100 * 0.8 = 80.
  3. Final Answer:

    80 -> Option C
  4. Quick Check:

    Refund calculation = 80 [OK]
Quick Trick: Check time condition before calculating refund [OK]
Common Mistakes:
  • Ignoring the time condition and returning full amount
  • Returning zero refund incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes