Question
Write the interface (.h file) of a class GasTank containing:
A data member named amount of type double.
A data member named capacity of type double.
A constructor that accepts a parameter of type double.
A function named addGas that accepts a parameter of type double and returns no value.
A function named useGas that accepts a parameter of type double and returns no value.
A function named isEmpty that accepts no parameters and returns a boolean value.
A function named isFull that accepts no parameters and returns a boolean value.
A function named getGasLevel that accepts no parameters and returns a double.
A function named fillUp that accepts no parameters and returns a double.
Solution
class GasTank
{
private:
double amount;
double capacity;
public:
GasTank(double);
void addGas(double);
void useGas(double);
bool isEmpty();
bool isFull();
double getGasLevel();
double fillUp();
};
Answers for C++ Course using "Starting out with C++ : from control structures through objects" by Tony Gaddis. 7/8th ed. I used the Pearson myprogramminglab to complete the homework. Here are my solutions/answers for the exercises/labs so please use the test bank as a GUIDE if you're stuck. Let me know if you find a better solution to a problem or any of the programming challenges. Thanks in advance for your support! Send in missing programming challenges to cplusplus.answers@gmail.com
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment