← Back to If Statements
Question 253
Parking Fee
Parking Fee
Two variables describe a parking stay: hours (may be fractional) and isWeekend (a boolean). The fee is 3 for the first hour and 2 for each additional hour or part of an hour, so useMath.ceilto round the hours up to a whole number first. The fee is capped at 20. On a weekend the final fee is halved. A stay of 0 hours costs nothing. Compute the fee into a variable called fee with if statements and printFee: <fee>.
Expected Output:
Fee: 13= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
If Statements
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (clog, fn, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.