Question: GasTank should have: - two instance variables, both double types: totalgallons (the capacity of a gas tank in gallons), and currentGallons (the number of gallons

GasTank should have: - two instance variables, both double types: totalgallons (the capacity of a gas tank in gallons), and currentGallons (the number of gallons of gas currently in the tank) - a no-argument constructor that sets totalgallons to 18.5 and currentgallons to 0. - public void fillup(), which sets currentgallons to totalgallons. - public void fillup (double gallons), which checks to make sure that the addition of the gallons argument to the currentGallons would not exceed the tank capacity. If it does, the method should print "Update denied. Gallons exceeded tank capacity.", and if it doesn't, the method should add gallons to currentGallons. - public void burnfuel (double gallons), which checks to make sure that the subtraction of the gallons argument from currentgallons does not go negative. If it does, the method should print "You can't burn that much: not enough fuel in tank.", and if it doesn't, the method should subtract gallons from currentGallons. - public double getTotalgallons() and public double getcurrentgallons(): two getters for the two instance variables. - No main method
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
