#385 Applying a Customer Discount to a Cart
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
Sign in to start the dialogue
The mentor keeps the context of the current question and your previous messages.
Sign in
Available with Premium
This is just one of the solutions available with Premium. And more:
- 250+ advanced lectures
- 1300+ practice exercises
- 500+ solutions to problems from real interviews
- Personalized Java Hub certificates
- Expanded access to the AI mentor