← Back to Classes
Question 496
Car Odometer
Car Odometer
A Car stores its make, an odometer reading in km and a trips count that starts at 0. Write the body of drive so one call adds km to the odometer and adds one to the trip count; nothing is returned. Do NOT write a main block or any top-level test code; the tests construct the class. Input: one line, the distance of the trip, which the tests read as a float and pass to drive on a car whose odometer starts at 1200.0; the tests then print the odometer and the trip count on separate lines.
Expected Output:
1255.5 1
= newline. The output ends with a newline — print one after the last line.
Hints2 available
Sign in to use hintsTopics:
Classes
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.