Question: Show me the steps to solve Define a class called Vehicle that will be used to check the amount of fuel left in a vehicle

Show me the steps to solve Define a class called Vehicle that will be used to check the amount of fuel left in a vehicle after
traveling a certain distance. The class should have the instance variable tankSize to store the initial
size of the tank and efficiency to store initial efficiency of the vehicle. Set to zero the variable
fuelInTank that is used to store the initial amount of fuel in a tank. Include accessor methods that
returns tankSize, efficiency and fuelInTank. Include an accessor method
availableTankCapacity that calculates how much fuel can be filled depending on the fuel
existing in the tank and the tanks capacity.
Include a mutator method addPetrol to add petrol in the tank. This method receives number of
gallons to add in the tank and checks the tanks capacity before adding the petrol. If the available
tanks capacity is less than the amount of gallon received to fill in the tank, this will print an error
message and adds the petrol otherwise.
Also, include a method driveTo that returns what distance can be traveled with the available fuel
and provided efficiency.
The class must include the variety of constructors (no-argument, parametrized, and copy constructor),
a toString and the equals methods.
Use your class with a test program. You should decide which variables should be public, if any. Also,
define if any other method(s) are needed. in 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 Finance Questions!