Compute the late payment fee
A billing system charges a fixed fee for the first overdue day and a smaller increment for each additional day.
- The first overdue day costs 2500.
- Each further day adds 500.
- Zero or fewer overdue days means no fee.
LateFee(daysLate: int) → int
C# needs a compiler and Drill does not host one yet, so this page is the reference rather than an exercise: the problem, worked examples, and the solution in full. To type it out, the same problem runs in Python.
Where you start
public int LateFee(int daysLate) {
}
Worked examples
| Call | Result |
|---|---|
LateFee(1) | 2500 |
LateFee(2) | 3000 |
LateFee(5) | 4500 |
LateFee(0) | 0 |
Hint
Subtract one from the count, multiply the increment, and add the base — but only when positive.
Reference solution in C#
public int LateFee(int daysLate) {
if (daysLate <= 0) return 0;
return 2500 + (daysLate - 1) * 500;
}