Online Store Profit

An online store sells a product for $45 per item. It costs $20 per item to produce. The store also pays $200 per month for shipping. They get a bulk order discount of $10 off per item for orders over 50 items. Write an expression for the total profit (n items > 50).

$45
Selling Price
Discounted Price: $35n
-
Why "-"?Subtracting costs
$20
×
n
Production Cost
Variable Cost per Item
-
Why "-"?Fixed expenses
$200 Fixed
Shipping & Storage
=
(45-10)n - 20n - 200
Profit Equation

Online Store Profit

To find profit, we need to subtract ALL costs from our revenue. Sometimes prices change based on quantity (discounts).
Continue

1. Revenue with Discount (+)

Product price is $45, but for bulk orders (>50), we give a $10 DISCOUNT. So, revenue per item is ($45 - $10) = $35. For n items: 35n.
Continue

2. Variable Costs (-)

It costs $20 to produce each item. This scales with quantity: -20n.
Continue

3. Fixed Expenses (-)

Shipping and storage is a flat $200 per month: -200.
Continue

4. Final Expression

Combine terms: (35n) - (20n) - 200. Simplify: 15n - 200.
Continue

Your Turn

Practice with new numbers. Note how discounts affect the 'per item' rate.
Continue

E-commerce Logic

Handling bulk discounts is a core feature of pricing engines.

calculateStoreProfit.ts
function calculateMonthlyProfit(itemsSold: number): number {
  const basePrice = 45;
  const costPerItem = 20;
  const fixedCost = 200;
  
  // Logic: Apply discount if applicable
  let price = basePrice;
  if (itemsSold > 50) {
      price -= 10; // Discounted price is $35
  }

  // Revenue = Price * Quantity
  const revenue = price * itemsSold;
  
  // Total Cost = (Variable * Quantity) + Fixed
  const totalCost = (costPerItem * itemsSold) + fixedCost;

  return revenue - totalCost;
}

// 100 items (Bulk Discount Applies):
console.log(calculateMonthlyProfit(100));
// Revenue: 35 * 100 = 3500
// Cost: (20 * 100) + 200 = 2200
// Profit: 1300
Discount Logic Implementation
AlgoAnimator: Interactive Data Structures