Assignment 9 Answers
a) Bugs
a. Format in printf for miles on bill is wrong ( %d for double variable )
b. Fine calculation doesn’t properly check for ranges e.g. between 5 and 10 mph over limit instead of just less than 10 mph over limit. Anybody less than 10 mph over the limit will be overcharged, as will non speeders
c. Line 201 does integer division – will always end up with 0% or 100% speeders – need to adjust to avoid truncation (masked somewhat by problem b)
d. totalFines is never initialized – causes several problems on final report – total fines, ave per speeding car, ave for all cars.
b) Variable Values
i) Fine 168.48
ii) miles 34
iii) totalFines -9.2559631349318e+061
iv) numSpeeding 3