|
|
|
© 1998 by Bobby Griggs.
// Chapter 4 program requiring functions to perform program details.
// Program name: Paint
// Win32 console applications
#include < iostream.h >
#include < stdio.h >
#include < iomanip.h >
void dimensions (double &l,double &w);
void price (double &wp,double &cp);
void wallfigures (double &wa,double &wg,double wpg,double &wc);
void ceilingfigures (double &ca,double &cg,double cpg,double &cc);
void display(double wg,double cg,double wc,double cc);
const double HEIGHT = 8.0;
const double COVER = 250.0;
double lengt,width,wallarea,ceilingarea;
double wallgals,ceilinggals,wallpergal,ceilingpergal;
double wallcost,ceilingcost;
void main()
{
dimensions (lengt,width);
price (wallpergal,ceilingpergal);
wallfigures (wallarea,wallgals,wallpergal,wallcost);
ceilingfigures (ceilingarea,ceilinggals,ceilingpergal,ceilingcost);
display(wallgals,ceilinggals,wallcost,ceilingcost);
cout << "Hit enter to continue ... " << endl;
getchar();
}
void dimensions (double &l,double &w)
{
cout << "Enter room length ... ";
cin >> l;
cout << endl;
cout << "Enter room width ... ";
cin >> w;
cout << endl;
return;
}
void price (double &wp,double &cp)
{
cout << "Price of wall paint ... ";
cin >> wp;
cout << endl;
cout << "Price of ceiling paint ... ";
cin >> cp;
cout << endl;
return;
}
void wallfigures (double &wa,double &wg,double wpg,double &wc)
{
wa = 2 * (width * HEIGHT) + 2 * (lengt * HEIGHT);
wg = wa / COVER;
wc = wg * wallpergal;
return;
}
void ceilingfigures (double &ca,double &cg,double cpg,double &cc)
{
ca = width * lengt;
cg = ca / COVER;
cc = cg * ceilingpergal;
return;
}
void display(double wg,double cg,double wc,double cc)
{
cout << setiosflags(ios::fixed) << setprecision(2);
cout << "Gallons for wall ... " << wg << endl;
cout << "Gallons for ceiling ... " << cg << endl;
cout << endl;
cout << "Wall cost ... " << wc << endl;
cout << "Ceiling cost ... " << cc << endl;
cout << endl;
cout << "Total cost ... " << wc + cc << endl;
cout << endl;
return;
}
|