Question: C++ program. Write a Car class that has member variables tank and speed. Create a function called pumpGas. An exception has to be thrown when

C++ program. Write a Car class that has member variables tank and speed. Create a function called pumpGas. An exception has to be thrown when a negative value is passed to the function pumpGas. Another exception must be thrown if the value of tank become more than 15 gallons when an value is passed to the function. For example: If the user ask to pump 10 gallons of gas and he or she already have 8 gallons in the tank, then an exception should be thrown to indicate that his or her tank has exceeded the maximum storage of the tank, and that display the specific exceeding and amount (10+8=18>15, 18-15=3, 3 gallons in the example). Lastly, display the refund 3gallons* $4=$12 back to the user. I am thinking of using if loops, double tank, double gasInput, tank+=gasInput; if (tank>=0&&tank else if (tank>15){.....}
thankyou.
 C++ program. Write a Car class that has member variables tank

Class Assignment 9 Due: July-11-2017 Name: Write the Car class that has tank and speed as member variables. If a negative value is passed to the furiction pumpGas, an exception must be thrown. Also if a value is passed that will make the value of tanik more than 15 another exception must be thrown. For example if you ask to pump 10 gallons of gas and you already have 8 gallons in the tank, so the exception that is thrown should indicate that you have asked for 3 extra gallons and the catch block should return 3 $4 $12 back to you

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!