#include <iostream>
#include <cstdlib>
using namespace std;
double amountSold;
double galSold;
double price;
int start;
int pump;
int main()
{
price = 2.85;
galSold = 0;
pump = 1;
while(pump==1)
{
cout << "Sales Total " << amountSold << endl;
cout<< endl;
cout << "Gallons Of Gas Sold " <<galSold;
cout<< endl;
cout << endl;
cout << "Price per Gallon $ "<<price;
cout << endl;
cout << endl;
cout<< "Start Pump? Enter 1 to start and -1 to end " <<endl;
cin>> start;
if (start == 1)
{
for (amountSold=0; amountSold<20.00; amountSold=amountSold+0.01)
{
galSold = amountSold/price;
system("CLS");
cout << "Sales Total " << amountSold << endl;
cout<< endl;
cout << "Gallons Of Gas Sold " <<galSold;
cout<< endl;
cout << endl;
cout << "Price per Gallon $ "<<price;
cout << endl;
cout << endl;
}// end of for loop
}//end of if
else
{
cout<< "Start Pump? " <<endl;
cin>> start;
} // end of else
system("CLS");
}
}// end of int main
I am trying to program a very basic gas pump for my intro to C++ class. Unfortunently my teacher was an idiot and i ended up teaching myself most of it. The two issues i cant seem to figure out are how to accept a user input to start and stop the gas pumping loop and how to pause the loop at the start so that it appears to "zero out" before pumping gas. Any help is welcome and if you see some mistakes other than that in the code feel free to comment. I am always open to suggestions and learning.
Thanks an Advance!
-David