Write a class called fueler that can keep track of the fuel and mileage of a vehicle.

Question:

Write a class called fueler that can keep track of the fuel and mileage of a vehicle. Include private instance variables to track the amothuent of fuel that the vehicle has consumed and the distance that the vehicle has traveled. You may choose whatever units you like (for example, fuel could be measured in U.S. gallons, Imperial gallons, or liters), but be sure to document your choices at the point where you declare the variables.

The class should have a constructor that initializes these variables to zero. Include a method that can later reset both variables to zero. There are two different modification methods to add a given amount to the total distance driven (one has a miles parameter, and the other has a kilometers parameter); similarly, there are three methods to add a given amount to the total fuel consumed (with different units for the amount of fuel).

The class has two accessor methods to retrieve the total distance driven (in miles or km), three methods for the fuel consumed (in U.S. gallons, Imperial gallons, or liters), and four for the fuel mileage (in U.S. mpg, Imperial mpg, km per liters, or liters per 100 km).

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: