Answer:
The class GasTank is defined below
All the steps are briefed in comments
public class GasTank {
// instance variable initialization
private double amount = 0;
//declaring instance variable capacitance
private double capacity;
//constructor having parameter of type double
public GasTank(double i)
{
capacity = i;
}
// addGas method for increasing gas quantity.
public void addGas(double i)
//quantity of gas increased is added to the existing amount. If it becomes more than total capacity, amount is set to capacity
{ amount += i; if(amount > capacity) amount = capacity; / amount = amount < capacity ? amount+i : capacity;/ }
//useGas method having parameter of type double
public void useGas(double i)
//the parameter given is deducted from 0 and if results less than 0, remains equal to 0
{ amount = amount < 0 ? 0 : amount - i; }
//method isEmpty
public boolean isEmpty()
//Returns true if volume is less than 0.1 else false
{ return amount < 0.1 ? true : false; }
//method isFull
public boolean isFull()
//returns true if the value of amount is greater than 0.1 else false.
{ return amount > (capacity-0.1) ? true : false; }
//method getGasLeve
public double getGasLevel()
//Returns the value of amount instance variable
{ return amount; }
//method fillUp
public double fillUp()
//returns the difference between the capacity and the amount
{ double blah = capacity - amount; amount = capacity; return blah; }
}