46.3 - Parcel Delivery Calculator, part 3 — extra complexity (JS lessons — arguments and return)
📘 Task: Parcel Delivery Calculator 3.0
This is a continuation of the previous task. The architecture stays the same — the same
4 functions (3 calculators + 1 main), the function signatures don't change.
🧩 Main condition
Only touch the logic inside calculateWeightCost,
calculateDistanceCost and calculateUrgentSurcharge.
The main function calculateTotalCost() — stays unchanged.
💰 New rates:
- 📦 Base fee — 15 $ (unchanged)
- ⚖️ Weight:
— up to 20 kg inclusive — regular rate 3 $/kg
— more than 20 kg, but not more than 50 kg — rate 1.5 $/kg (heavy parcel)
— more than 50 kg — rate 1 $/kg (very heavy, bulk shipment)
- 📏 Distance:
— up to 15 km inclusive — regular rate 2 $/km
— more than 15 km, but not more than 40 km — rate 1.5 $/km (long-distance delivery)
— more than 40 km — rate 1 $/km (very long-distance delivery)
- 🚀 Urgency surcharge:
— not express — no surcharge
— express and amount 60 $ or less — +25%
— express and amount greater than 60 $, but not more than 100 $ — +15%
— express and amount greater than 100 $ — +10%