subject

Write a full class definition for a class named GasTank , and containing the following members: A data member named amount of type double.
A constructor that no parameters. The constructor initializes the data member amount to 0.
A function named addGas that accepts a parameter of type double . The value of the amount instance variable is increased by the value of the parameter.
A function named useGas that accepts a parameter of type double . The value of the amount data member is decreased by the value of the parameter. However, if the value of amount is decreased below 0 , amount is set to 0 .
A function named isEmpty that accepts no parameters and returns a boolean value. isEmpty returns a boolean value: true if the value of amount is less than 0.1 , and false otherwise.
A function named getGasLevel that accepts no parameters. getGasLevel returns the value of the amount data member.
class GasTank
{
private:
double amount;
public:
GasTank();
void addGas(double);
void useGas(double);
bool isEmpty();
double getGasLevel();
};
GasTank::GasTank(){amount = 0;}
void GasTank::addGas(double a){amount += a;}
void GasTank::useGas(double a){amount -= a; if (amount < 0) amount = 0; }
bool GasTank::isEmpty(){if(amount < .1) return true; else return false;}
double GasTank::getGasLevel() {return amount;}

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 05:30, xbeatdroperzx
Gerard is currently working as an entry-level customer support technician, but he would like to someday become a software developer. what is the best first step to understand what he should do? ask his manager for a new job or at least a job recommendation study graphic design in order to obtain the necessary skills use career resources to investigate what skills and education are required work part-time as an entry-level web developer question 13 (true/false worth 6 points) (08.03 lc) career resources are used to explore career options and find career information. true false question 14(multiple choice worth 6 points) (08.01 mc) classify the following skills: writing html code, evaluating color theory, using design principles. hard skills interpersonal skills people skills soft skills question 15 (true/false worth 6 points) (08.03 lc) a mentor is a person who is advised, trained, or counseled by a trusted mentee. true false
Answers: 2
image
Computers and Technology, 22.06.2019 08:00, jcastronakaya
Apex q: what does a low employment rate indicate? a. not many people are earning high salaries b. not many people are going to college c. not many people are renting their homes d. not many people have jobs
Answers: 2
image
Computers and Technology, 22.06.2019 11:30, LindseyN1
One subtask in the game is to roll the dice. explain why is roll the dice an abstraction.
Answers: 3
image
Computers and Technology, 24.06.2019 06:00, bzhsh8282
Hey i really need some solving this problem: 1. encrypt this binary string into cipher text: 110000. include in your answer the formula the decoder would use to decrypt your cipher text in the format (coded answer) x n mod (m) = y & 2. decrypt this cipher text into a binary string: 106 you.
Answers: 2
You know the right answer?
Write a full class definition for a class named GasTank , and containing the following members: A d...

Questions in other subjects:

Konu
Mathematics, 14.12.2020 04:50
Konu
English, 14.12.2020 04:50
Konu
Health, 14.12.2020 04:50
Konu
Mathematics, 14.12.2020 05:00