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

I already completed the first part of the assignment, just having trouble puttin

ID: 3709710 • Letter: I

Question


I already completed the first part of the assignment, just having trouble putting this little part in. I will also attach the part I did

Can anyone please help me ?? TutorsLTE 5:52 PM s3.amazonaws.com CSC 211/Classes and Static Variables and Functions Lab Assignment Part B Keep on Pumping! Keep on Pumping! Modify your pump class by adding a static data member that is shared by all pump objects, to keep track of the amount of gas in the main tank. This static variable should be initialized to 0 Additionally add 2 static member functions to the pump class: I. A static function to fill the main tank with the # of gallons passed as an argument (add this amount to the static data member). 2, A static function to return the # of gallons in the main tank. Modify your 2 dispensin of gas left in the main tank. Dispensing should stop if the main tank is empty, a message should be displayed to the user, and the main tank should be filled. g functions to monitor the amount Add one final method that prints the totals for the program run to a log file, i.e. the number of gallons sold by the full serve pump, the number of gallons sold by the self serve pum p and the amount of gas remaining in the main tank. Prompt the user for the desired name of this log file. Once you have completed Part B and tested it thoroughly with an appropriate driver program. Your program should be broken into 3 files for separate compilation. Create a header file (.h) for the class interface, acpp file for the implementation and a cpp file for the driver

Explanation / Answer

#include <iostream>

using namespace std;

class GasPump

{

public:

void initialize();

void reset();     

void displayExpenditurePerGallon();

void displayGasAndCharges();

void distribute();

void stop();

private:

double gasDistributed;

double charge;

public:

void setPricePerGallon(double newPrice);

void purchaseFromJobber(double quantity);

void displayQuantityInMainTank();

private:

    double gasInMainTank;

    double ExpenditurePerGallon;

};

void GasPump::displayQuantityInMainTank()

{

cout << gasInMainTank;

}

void GasPump::setPricePerGallon(double newPrice)

{

ExpenditurePerGallon = newPrice;

}

void GasPump::purchaseFromJobber(double quantityBought)

{

   gasInMainTank += quantityBought;

}

void GasPump::initialize()

{

gasDistributed = 0;

charge = 0;

gasInMainTank = 0;

}

void GasPump::reset()

{

gasDistributed = 0;

charge = 0;

}

void GasPump::displayExpenditurePerGallon()

{

cout << ExpenditurePerGallon;

}

void GasPump::displayGasAndCharges()

{

cout << "gallons: " << gasDistributed

       << "   $"      << charge << endl;

}

void GasPump:: distribute()

{

   char quit;

   system("cls");   

   cout << " DISTRIBUTED FUEL ";

   displayGasAndCharges();

   cout << " Press <CR> to distribute in 0.1 gallon increments. "

        << " Press v or V <CR>to terminate distributed. ";

   while(gasInMainTank > 0)

   {    

     quit = cin.get();

     if (quit == 'v' || quit == 'V')

          break;

     charge += 0.1 * ExpenditurePerGallon;

     gasDistributed += 0.1;

     gasInMainTank -= 0.1;

     system("cls");    

     cout << " DISTRIBUTED FUEL ";

     displayGasAndCharges();

     cout << " Press <CR> to distribute in 0.1 gallon increments. "

           << " Press v or V <CR>to terminate distributed. ";

   }

   if(0 == gasInMainTank)

     cout << "Distributed ceased because main tank is empty. ";

}

int main()

{

cout.setf(ios::fixed);

cout.setf(ios::showpoint);

cout.precision(2);

GasPump pump;

char ans;

cout << "Gas Pump Modeling Program ";

pump.initialize();

pump.setPricePerGallon(1.50);

pump.purchaseFromJobber(25);

cout << "Amount of gasoline in main tank is: ";

pump.displayQuantityInMainTank();

cout << endl;

cout << "Gasoline price is $";

pump.displayExpenditurePerGallon();

cout << " per gallon. ";

pump.displayGasAndCharges();

cout << "Press Y/y <CR> to run the dispensing model,"

       << " anything else quits. ";

cin >> ans;

if( !('Y' == ans || 'y' == ans) )

     return 0;

system("cls");    

cout << " Welcome Customer #1 ";

cout << "Press Y/y <CR> to start dispensing Fuel,”

       << “ other quits ";

cin >> ans;

if('Y'==ans || 'y' == ans)

{

     ans = cin.get();

     pump.distribute();

}

cout << "Thank you. Your charges are: " ;

pump.displayGasAndCharges();

cout << endl;

cout << " Amount of gasoline remaining in main tank is: ";

pump.displayQuantityInMainTank();

cout << " gallons ";

cout << " Welcome Customer #2 ";

pump.displayGasAndCharges();

  

cout << "Press Y/y <CR> to start dispensing Fuel,"

       << " anything else quits dispensing. ";

cin >> ans;

if('Y'==ans || 'y' == ans)

{

     pump.reset();

     ans = cin.get();

     pump.distribute();

}

cout << "Thank you. Your charges are: " ;

pump.displayGasAndCharges();

cout << endl;

cout << " Amount of gasoline remaining in main tank is: ";

pump.displayQuantityInMainTank();

cout << " gallons ";

return 0;

}