Sectionย 2. Chapterย 1
single
Challenge: Parking Fee Calculator
Swipe to show menu
Task
Swipe to start coding
You are building a parking management system. Each vehicle type pays a different fee depending on the parking zone.
- Check the car type using
ifandelse if:- If the car is
"compact", use aswitchstatement onzoneto assign the fee:- Zone 1 โ $5.0
- Zone 2 โ $3.0
- Other zones โ $4.0
- If the car is
"SUV", use aswitchstatement onzoneto assign the fee:- Zone 1 โ $8.0
- Zone 2 โ $6.0
- Other zones โ $7.0
- For other car types, set the fee to $0.0.
- If the car is
- Return the fee from the function.
Solution
Everything was clear?
Thanks for your feedback!
Sectionย 2. Chapterย 1
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat