5 XP challenge

Price after a Threshold

very easy
Build it yourself · 3 min
1 Learn2 Predict3 Solve

Task
Your mission

Return quantity * unitPrice, subtracting discount once if that total is at least threshold. quantity and unitPrice are 0 to 20; threshold is 1 to 100; discount is 0 to threshold.

Examples

InputReturn
quantity = 3, unitPrice = 5, threshold = 15, discount = 2

total: 15 → 13. The result is 13.

13
quantity = 2, unitPrice = 5, threshold = 15, discount = 210

Your code

Write your answer inside Solution, then use return to send it back.

Try examples runs the public examples. Check my code checks your full answer and saves your completion.