Bird
0
0

What will be the output of the following code?

medium📝 Analysis Q5 of 15
LLD - Design — Food Delivery System
What will be the output of the following code?
menu = Menu()
menu.add_item('Pizza', 8.0)
order = Order()
order.add_item('Pizza', 1)
order.add_item('Soda', 2)
total = order.calculate_total(menu)

Assuming 'Soda' is not in the menu.
A0.0
B8.0
C16.0
DError: Item not found
Step-by-Step Solution
Solution:
  1. Step 1: Check if all ordered items exist in the menu

    'Soda' is not in the menu, so the system should handle this case.
  2. Step 2: Determine expected behavior

    Typically, an error or exception is raised when an ordered item is missing from the menu.
  3. Final Answer:

    Error: Item not found -> Option D
  4. Quick Check:

    Missing menu item causes error [OK]
Quick Trick: Orders must match menu items; missing items cause errors [OK]
Common Mistakes:
  • Ignoring missing items
  • Returning zero instead of error
  • Counting missing items as zero price

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes