Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi everyone, I am struggling here with the GasPump class. I gotpart of it done b

ID: 3616443 • Letter: H

Question

Hi everyone,
   I am struggling here with the GasPump class. I gotpart of it done but I am having some issues with the dispensemethod. I am posting my work below, please help me out. Thanks!Here is how the output should look like
 Amount of gasoline in main tank is: 25.00
Gasoline price is $1.50 per gallon.
gallons: 0.00 $0.00
Press Y/y <CR> to run the dispensing model, anything else quits.
y

// >>>>>>> screen clears with system("cls"); in windows, system("clear") in linux/unix


Welcome Customer #1
Press Y/y <CR> to start dispensing Fuel, other quits
y


// >>>>>>> screen clears with system("cls"); in windows, system("clear") in linux/unix

DISPENSING FUEL
gallons: 0.00 $0.00

Press <CR> to dispense in 0.1 gallon increments.
Press q or Q <CR>to terminate dispensing.

// >>>>>>> screen clears after hitting return key once


DISPENSING FUEL
gallons: 0.10 $0.15

Press <CR> to dispense in 0.1 gallon increments.
Press q or Q <CR>to terminate dispensing.


// >>>>>>> screen clears after hitting return key the second time


DISPENSING FUEL
gallons: 0.20 $0.30

Press <CR> to dispense in 0.1 gallon increments.
Press q or Q <CR>to terminate dispensing.

// >>>>>>> screen clears after hitting return the third time


DISPENSING FUEL
gallons: 0.30 $0.45

Press <CR> to dispense in 0.1 gallon increments.
Press q or Q <CR>to terminate dispensing.
q

// q completes the process for the customer 1


DISPENSING FUEL
gallons: 0.20 $0.30

Press <CR> to dispense in 0.1 gallon increments.
Press q or Q <CR>to terminate dispensing.
q
Thank you. Your charges are:
gallons: 0.20 $0.30



Amount of gasoline remaining in main tank is: 24.80 gallons


Welcome Customer #2
gallons: 0.20 $0.30
Press Y/y <CR> to start dispensing Fuel, anything else quits dispensing.

#include <iostream>
#include <cstdlib>
using namespace std;
class GasPump{
public:
//GasPump(double a, double b);
void displayGas();
void setAmountGas(double );
void setPrice(double );
void displayPricePerGallon();
void setAmountCharged(double );
void dispense();
void reset();
void displayGasNCharges();
void displayInfo();
void setGasDispensed(double );
private:
double gasInTank;
double costPerGallon;
double gasDispensed;
double charge;
};
int main(){
   GasPump p;
   p.setPrice(1.5);
   p.setGasDispensed(0.0);
   p.setAmountCharged(0.0);
   p.setAmountGas(25.0);
   cout<<"Gas Pump ModelingProgram"<<endl;
   p.displayInfo();
   p.displayGasNCharges();
   p.dispense();
   system("cls");
   system("pause");
}
void GasPump::displayGasNCharges(){
cout <<"gallons: "<<gasDispensed<<" "<<" $"<<charge<<endl;
}
void GasPump::displayInfo(){
   cout<<"Amount of gasoline in main tank is:";
   displayGas();
   cout<<endl;
   cout<<"Gasoline price is $";
   displayPricePerGallon();
   cout<<" per gallon. ";
}
void GasPump::reset(){
gasDispensed=0;
charge=0;
}
void GasPump::dispense(){
char temp;
cout <<" Dispensing Fuel ";
displayGasNCharges();
cout<<" Press Enter to dispense in 0.1 gallonincrement"<<endl;
cout<<"Press q or Q <CR> to terminatedispensing";
while(gasInTank>0.1){
cin>>temp;
if(temp == 'q'|| temp= 'Q')
   break;
   charge+=0.1*costPerGallon;
   gasDispensed-=0.1;
   gasInTank-=0.1;
   displayGasNCharges();
}
}

void GasPump::setPrice(double b){
costPerGallon=b;
}
void GasPump::displayGas(){
cout<<gasInTank;
}
void GasPump::setAmountGas(double a){
gasInTank=a;
}
void GasPump::displayPricePerGallon(){
   cout<<costPerGallon;
}
void GasPump::setGasDispensed(double c){
gasDispensed=c;
}
void GasPump::setAmountCharged(double d){
charge=d;
}


Explanation / Answer

please rate - thanks hope this helps #include #include using namespace std; class GasPump{ public: //GasPump(double a, double b); void displayGas(); void setAmountGas(double ); void setPrice(double ); void displayPricePerGallon(); void setAmountCharged(double ); void dispense(); void reset(); void displayGasNCharges(); void displayInfo(); void setGasDispensed(double ); private: double gasInTank; double costPerGallon; double gasDispensed; double charge; }; int main(){    GasPump p;    p.setPrice(1.5);    p.setGasDispensed(0.0);    p.setAmountCharged(0.0);    p.setAmountGas(25.0);    cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote