QuestionQ116

VerifiedControl Flow – Conditional Blocks and Loops

ABC Video needs a way to calculate the amount a customer pays to rent a DVD. The cost depends on the time of day the DVD is returned, with special rates on Thursdays and Sundays. The fee structure is as follows:

  • The charge is $1.59 per night.
  • If the DVD is returned after 8 PM, the customer is charged for an additional day.
  • If the video is rented on a Sunday, the customer receives 30% off for however long they keep it.
  • If the video is rented on a Thursday, the customer receives 50% off for however long they keep it.

Write code that meets these requirements.

Question Image

What should be inserted in place of XXX, YYY, and ZZZ?

Explanation

An additional day applies when the return was not before 8 PM, represented by ontime == 'n'. A Sunday rental costs 70% of the standard amount after a 30% discount, and a Thursday rental costs 50% after a 50% discount. The day names are string values and must be tested with ==.

Community Discussion

No comments yet. Be the first to start the discussion!