#385 Applying a Customer Discount to a Cart

Companies:
Yandex
Themes:
JavaOOPPractice

You are a backend developer at the online store “Horns and Hooves.” Business is going well, and the store has decided to increase customer loyalty by providing personalized discounts.

A product owner asks you to create a simple loyalty system that provides a percentage discount for a shopping cart. The discount amount depends on the customer. The analysts have already determined which discounts must be provided to customers.

A cart is a list of the customer's products.

Product:

  • id
  • price
  • final price including the discount

Discount: a percentage discount may be assigned to a customer as an integer.

Implement the part of the system that:

  • accepts the customer id and cart as input;
  • calculates and applies discounts;
  • returns the cart with the discounts applied. The discount must be reflected in the purchase price.

Question review

Mentor
Answer as you would in a real interview. I’ll ask follow-up questions, then compare your answer with the reference answer and show your accuracy as a %.
Sign in to start the dialogue The mentor keeps the context of the current question and your previous messages.
Sign in