Challenge: Parking Fee Calculator
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
if
andelse if
:- If the car is
"compact"
, use aswitch
statement onzone
to assign the fee:- Zone 1 → $5.0
- Zone 2 → $3.0
- Other zones → $4.0
- If the car is
"SUV"
, use aswitch
statement onzone
to 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.
Example
calculateParkingFee("compact", 1)
→ 5.0
calculateParkingFee("SUV", 3)
→ 7.0
calculateParkingFee("truck", 2)
→ 0.0
Solução
solution.cpp
Obrigado pelo seu feedback!
single
Pergunte à IA
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo
Can you explain this in simpler terms?
What are the main points I should remember?
Can you give me an example?
Awesome!
Completion rate improved to 7.69
Challenge: Parking Fee Calculator
Deslize para mostrar o menu
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
if
andelse if
:- If the car is
"compact"
, use aswitch
statement onzone
to assign the fee:- Zone 1 → $5.0
- Zone 2 → $3.0
- Other zones → $4.0
- If the car is
"SUV"
, use aswitch
statement onzone
to 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.
Example
calculateParkingFee("compact", 1)
→ 5.0
calculateParkingFee("SUV", 3)
→ 7.0
calculateParkingFee("truck", 2)
→ 0.0
Solução
solution.cpp
Obrigado pelo seu feedback!
single