- 5.5 Figure 5.9 Program to Monitor Gasoline Storage Tank
#include <iostream>
#define capacity 80000.0
#define min_pct 10
#define gals_per_brl 42.0
double monitor_gas(double min_supplay,double start_supply);
using namespace std;
int main(void)
{
double start_supply, min_supply, current;
min_supply = min_pct/100.0*capacity;
cout<<"Number of barrels currently in tank> ";
cin>>start_supply;
current = monitor_gas(min_supply,start_supply);
cout<<"only barrels are left."<<current<<endl<<endl;
cout<<"*** WARNING ***"<<endl;
cout<<"Available supply is less than percent of"<<min_pct<<"tank's "<<endl;
cout<<capacity<<"barrel capacity."<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
double monitor_gas(double min_supply, double start_supply)
{
double remov_gals, remov_brls,current;
for (current = start_supply; current >= min_supply; current -= remov_brls){
cout<<"barrels are available."<<current<<endl<<endl;
cout<<"Enter number of gallons removed> ";
cin>>remov_gals;
remov_brls = remov_gals/gals_per_brl;
cout<<"After removal of"<<remov_gals<<" gallone {"<<remov_brls<<" barrels)"<<endl;
}
return (current);
}
RUN :
0 komentar:
Posting Komentar