A painting company has determined that for every 115 square feet of wall space t
ID: 3653836 • Letter: A
Question
A painting company has determined that for every 115 square feet of wall space to be painted, one gallon of paint and eight hours of labor will be required. The company charges $18.00 per hour for labor. Write a program that will ask a user for the square feet of wall space to be painted and the price of paint per gallon. The program should display the number of square feet to be covered, the cost of paint, the cost of labor and the total cost. Do not accept a value less than $10.00 per gallon for the price of paint. At a minimum write and call a function for each of the following tasks:Explanation / Answer
please rate - thanks
#include <iostream>
#include<iomanip>
using namespace std;
int numGals(float);
float paintPrice();
float wallArea();
float laborHrs(float);
void displayCost(int,float,float,float );
int main()
{int gals;
float ppg,wall,hrs;
ppg=paintPrice();
wall=wallArea();
gals=numGals(wall);
hrs=laborHrs(wall);
displayCost(gals,ppg,hrs,wall);
system("pause");
return 0;
}
void displayCost (int gal, float price, float hrs,float wall)
{ float total,labor,paint;
paint=price*gal;
labor=hrs*34;
total=paint+labor;
cout<<"wall area painting: "<<setw(6)<<fixed<<setprecision(2)<<wall<<endl;
cout<<"Gallons of paint: "<<setw(6)<<fixed<<setprecision(2)<<gal<<endl;
cout<<"Hours labor: "<<setw(6)<<fixed<<setprecision(2)<<hrs<<endl;
cout<<"Paint cost: $"<<setw(6)<<fixed<<setprecision(2)<<paint<<endl;
cout<<"Labor cost: $"<<setw(6)<<fixed<<setprecision(2)<<labor<<endl;
cout<<"Total cost: $"<<setw(6)<<fixed<<setprecision(2)<<total<<endl;
return;
}
float laborHrs(float area)
{float hr;
hr=area/115*2;
return hr;
}
float wallArea()
{int num;
cout<<"Enter wall area for room : ";
cin>>num;
return num;
}
float paintPrice()
{float n;
cout<<"Enter price per gallon of paint? ";
cin>>n;
while(n<10)
{cout<<"must be at least $10 ";
cout<<"Enter price per gallon of paint? ";
cin>>n;
}
return n;
}
int numGals (float area)
{int gal;
gal=(int)(area/115+.9);
return gal;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.