Hello, Can you please help me with this task? I am new to C++ and really need he
ID: 3865538 • Letter: H
Question
Hello, Can you please help me with this task? I am new to C++ and really need help... Thank you in advance.
write the implementation of member function addGas of class Gaslank. Assume member function implementation is outside the class specification detailed description of function addGas) As a reminder, here is a description of the members of class GasTank (note the . 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 type doubl arameter of type double and returns no value. The value of the amount data ber is increased by the value of the parameter. However, if the value of amount is increased beyond the value of capacity, amount is set to capacity . A function named useGas that accepts a parameter of type double and returns no value parameters and returns a boolean value isEmpty that áccepts no pan A function named isFull that accepts no parameters and return ncton hamed getGasLevel that accepts no parameters and returns dout . A functionExplanation / Answer
Note:
Note : Could you please check the code .If you required any changes Just intimate.I will modify it.Thank You.
________________
//Creating an GasTank class
class GasTank
{
// Declarin variables
private:
double amount;
double capacity;
public:
//Function Declarations
GasTank(double capacity);
void addGas(double amt);
void usegas(double amt);
bool isEmpty();
bool isFull();
double fillUp();
double getGasLevel();
};
//Function implementations
GasTank::GasTank(double capacity)
{
this->capacity = capacity;
this->amount = 0;
}
// This function will add gas
void GasTank::addGas(double amt)
{
if (amt > capacity)
this->amount = capacity;
else
this->amount = this->amount + amt;
}
// This function will subtract gas
void GasTank::usegas(double amt)
{
if (this->amount - amt < 0)
this->amount = 0;
else
this->amount = this->amount - amt;
}
// This function will check whether the tank is empty or not
bool GasTank::isEmpty()
{
if (amount < 0.1)
return true;
else
return false;
}
// This function will check whether the tank is full or not
bool GasTank::isFull()
{
if (amount > (capacity - 0.1))
return true;
else
return false;
}
// This function will return the gas level in the tank
double GasTank::getGasLevel()
{
return amount;
}
// This function will fill the tank to full
double GasTank::fillUp()
{
this->amount = this->amount + (capacity - amount);
return (capacity - amount);
}
_____________Could you rate me well.Plz .Thank You
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.