about | help | code help+videos | done | prefs |
Transport NSW is trialling a new system for highway toll. You need to pay $1 up to the first 10 kms, and after that the the toll adds 1 for every 10kms or part of. Thus, if you travel 32kms, its $1 for the first 10, another $2 for the second 10, another $3 for the third 10, and another $4 for the last km (even though you didn't use the full 10kms). Define a function that when passed the distance travelled in kms, returns the applicable toll. Mathematically, this can be done without using loops too. toll(31) → 10 toll(49) → 15 toll(505) → 1326 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 2 Post-solution available
Copyright Nick Parlante 2017 - privacy