Create a program company has determined that for every 115 square feet of wall s
ID: 3625461 • Letter: C
Question
Create a program company has determined that for every 115 square feet of wall space, one gallon of paint and eight hours of labor will be required. The company charges $18.00 per hour for labor. Write a modular program that allows the user to enter the number of rooms that are to be painted and the price of the paint per gallon. It should then display the following data:.The number of gallons of paint required
.The hours of labor required
.The cost of the the paint
.The labor of charges
.The total cost of the paint job
Input Validation: Do not accept a value less than 1 for the number of rooms. Do not accept a value less than $10.00 for the price of paint. Do not accept a negative value for square footage of wall space.
Explanation / Answer
please rate - thanks
you didn't specify the language, but your other questions were C++
#include <iostream>
#include <math.h>
using namespace std;
double Paint(double, int);
double Labor(int);
double Total(double,double);
void Output(double, int, double, double);
main()
{int i, numrun, sqft;
double cpg,costlabor,costpaint,totalcost;
cout<<"How many rooms of data do you have? ";
cin>>numrun;
while(numrun<1)
{cout<<"must be >=1 ";
cout<<"How many rooms of data do you have? ";
cin>>numrun;
}
for(i=0;i<numrun;i++)
{
cout<<"what is the square footage of the room? ";
cin>>sqft;
while(sqft<0)
{cout<<"must be >=0 ";
cout<<"what is the square footage of the room? ";
cin>>sqft;
}
do
{
cout<<"What is the cost per gallon of paint? ";
cin>>cpg;
if(cpg<10.)
cout<<"price not possible must be >=10 ";
}while(cpg<10);
costpaint=Paint(cpg,sqft);
costlabor=Labor(sqft);
totalcost=Total(costpaint,costlabor);
Output(totalcost,sqft,costpaint,costlabor);
}
system("pause");
return 0;
}
double Paint(double cpg, int sqft)
{ return ceil(sqft/115.)*cpg; //assuming you can't buy part of a can of paint so round up # cans needed
}
double Labor(int sqft)
{return sqft/115.*(18.00*8); //assuming you can spend part of an hour painting
}
double Total(double paint,double labor)
{return paint+labor;
}
void Output(double total, int sqft, double paint, double labor)
{cout<<"It will cost $"<<total<<" to paint "<<sqft<<" sq ft ";
cout<<"Paint costs $"<<paint<<" Labor cost $"<<labor<<" ";
cout<<labor/18.<<" hours of labor "<<" You will need "
<<ceil(sqft/115.)<<" gallons of paint (can't purchase a portion of a gallon) ";
return;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.