← Back to Classes
Question 527
Odometer Class
Odometer Class
Create a classOdometerwith a public double fieldMiles(starts at 0) and anAddTrip(double distance)method that adds the trip distance ontoMiles. Do not write aMainmethod. After trips of 12.5 and 7.5 the program prints the output shown in Expected Output.
Expected Output:
20= 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 · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cw, cr, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.