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
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