Question: Write a Car class having two private member variables called tank and speed. Write public methods called pumpGas and goFast. The method pumpGas gets an

Write a Car class having two private member variables called tank and speed. Write public methods called pumpGas and goFast. The method pumpGas gets an integer for the amount of gas that must be pumped. That value needs to be added to tank (no more than 20 gallons). It must return the amount of gas that is purchased ($4 per gallon). The method goFast should increase the speed by 5 each time it is called. Write a constructor for the above class that initialized both variables to zero. Write a toString to display both the tank and speed when the car is printed. Write the main code to test the above class.

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!