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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!