Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

=+a) What are the null and alternative hypotheses?

Answered: 1 week ago

Question

=+3. What does this public know about your organization?

Answered: 1 week ago

Question

Describe the factors influencing of performance appraisal.

Answered: 1 week ago

Question

What is quality of work life ?

Answered: 1 week ago

Question

b. Why were these values considered important?

Answered: 1 week ago