Question: Create a Java class named Odometer which can be used to calculate fuel and mileage for an automobile. The class should have instance data which

Create a Java class named Odometer which can be used to calculate fuel and mileage for an automobile. The class should have instance data which tracks the miles driven and the fuel efficiency in miles per gallon. Include a mutator method to reset the odometer to zero miles, a mutator method to set the fuel efficiency, a mutator method which accepts the miles driven for a trip and adds it to the odometer's total, and an accessor method that returns the number of gallons of gasoline that the vehicle has consumed since the last reset. Include a main method that creates an instance of the class and invokes the methods for testing. Save your solution in a file named Odometer.java
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
