Freelance Project

A freelancer is hired for a project. The base payment is $500. For every additional hour (h) worked beyond the agreed 20 hours, they earn $35 per extra hour. They also spend $50 on software tools. Write an expression for the total profit after paying for the tools.

$500
Base Pay
Fixed Income
+
Why "+"?Earning more money
$35
×
h
Extra Hours
Hourly Rate × Hours
-
Why "-"?Spending on expenses
$50 Tools
Expense Subtracted
=
500 + 35h - 50
Profit Equation

Freelance Project Profit

Calculating profit often involves adding income sources and subtracting expenses. Let's model a freelance contract.
Continue

1. Base Payment (+)

You start with a guaranteed base payment of $500. This is fixed income, so it's a positive starting value.
Continue

2. Extra Hours (+)

You earn $35 for every extra hour (h) worked beyond the 20-hour agreement. More work equals MORE money, so we ADD: +35h.
Continue

3. Expenses (-)

You spent $50 on tools. Since this money is leaving your pocket, we SUBTRACT it: -50.
Continue

4. Final Expression

Profit = Income - Expenses. Expression: 500 + 35h - 50. (You could simplify this to 450 + 35h, but laying it out clearly is often better for logic).
Continue

Your Turn

Practice modeling a scenario with base pay, hourly rates, and costs.
Continue

Profit Calculator

Business logic often simply translates these math expressions into functions.

calculateProfit.ts
function calculateProfit(extraHours: number): number {
  const basePay = 500;
  const hourlyRate = 35;
  const expenses = 50;
  
  // Expression: 500 + 35h - 50
  // Income (Base + Variable) - Expenses
  return basePay + (hourlyRate * extraHours) - expenses;
}

// 10 extra hours:
console.log(calculateProfit(10)); 
// 500 + (35 * 10) - 50
// 500 + 350 - 50 = 800
Profit Calculation Logic
AlgoAnimator: Interactive Data Structures