1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Juli2301 [7.4K]
3 years ago
10

Write a full class definition for a class named GasTank , and containing the following members:

Computers and Technology
1 answer:
Ierofanga [76]3 years ago
7 0

Answer:

Explanation:

The following class code is written in Java and includes all of the required methods as requested in the question...

package sample;

class GasTank {

   private double amount = 0;

   private double capacity;

   public GasTank(double initialAmount) {

       this.capacity = initialAmount;

   }

   public void addGas(double addAmount) {

       this.amount += addAmount;

       if (amount > capacity) {

           amount = capacity;

       }

   }

   public void useGas(double subtractAmount) {

       this.amount -= subtractAmount;

       if (amount < 0) {

           amount = 0;

       }

   }

   public boolean isEmpty() {

       return (amount < 0.1);

   }

   public boolean isFull() {

       return (amount > capacity - 0.1);

   }

   public double getGasLevel() {

       return amount;

   }

   public double fillUp() {

       double difference = capacity - amount;

       amount = capacity;

       return difference;

   }

}

You might be interested in
The main file type used when saving a powerpoint presentation is the?
weeeeeb [17]
I am pretty sure it is the XML format
6 0
3 years ago
There are two activities on your schedule, which are: 1) install server in lab 2) move server into the data center. however, the
astra-53 [7]
Quality Assurance or testing.
4 0
4 years ago
To create a new blank document, the user should _____. select New from the File tab select Open from the Quick Access toolbar se
Nataliya [291]
<span>select New from the File tab
Hope it helped!</span>
4 0
3 years ago
Read 2 more answers
Explain why a holiday on a cruise liner will be an ideal holiday​
liubo4ka [24]

Answer:

The great thing about a cruise holiday is that everyone in your party can please themselves yet still have a real holiday together. The kids can make new friends and take part in fun and educational activities during the day, while the adults unwind by the pool, learn a new skill or hit the casino.

3 0
2 years ago
The chemical symbol H represents which of the following elements?
scZoUnD [109]
The answer is D. Hydrogen
helium is He (just for extra knowledge)
4 0
3 years ago
Read 2 more answers
Other questions:
  • (Game Design) The ESRB was created by:
    8·1 answer
  • Write a php program that checks the elements of a string array named $passwords. use regular expressions to test whether each el
    8·1 answer
  • Isp servers are continually connected to a larger network, called a regional network, which, in turn, is connected to one of the
    6·1 answer
  • The _________keys include the home, end, and arrow keys.
    13·1 answer
  • Who is responsible for customer service?
    14·1 answer
  • Technologies that function within the established system are called
    12·1 answer
  • MULTIPLE CHOICE!!!
    5·2 answers
  • Which of these statements best compares P waves and S waves of an earthquake?
    5·1 answer
  • Need Help! Asap 7.5 code practice (Edhesive)
    8·2 answers
  • What is the typical drive letter for the hard drive?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!