Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started