Question: Write, in JAVA code, a class named GasTank containing: An instance variable named amount of type double, initialized to 0. A method named addGas that

Write, in JAVA code, a class named GasTank containing:

An instance variable named amount of type double, initialized to 0.

A method named addGas that accepts a parameter of type double. The value of the amount instance variable is increased by the valueof the parameter.

A method named useGas that accepts a parameter of type double. The value of the amount instance variable is decreased by the valueof the parameter.

A method named getGasLevel that accepts no parameters. getGasLevel returns the value of the amount instance variable.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!