Sobes.tech
Junior — Senior

Determining the final order price considering various discounts

livecode

Task condition

A retail store sells a variety of goods, and several types of discounts may be applied. For some customers, the following are offered:

  • a fixed 5% discount on the entire assortment regardless of the order amount;
  • a wholesale discount of 10% when purchasing a quantity of units exceeding a specified threshold;
  • a 15% discount when purchasing a specific product if its total cost exceeds a set limit (e.g., $100) and the customer takes at least 3 units;
  • a discount calculated from the total order cost, regardless of the types of goods included. It is necessary to implement a program that calculates the final purchase price considering all applicable discounts.
class Discount {
public:
    int price;
};

class regular_discount : Discount {

};

class opt_discount : Discount {

};

class End_price {

};