modify the program so that it can display the number of gallons of paint require
ID: 653556 • Letter: M
Question
modify the program so that it can display the number of gallons of paint required and the hours of labor required.
*********************************************************************************************************************
#include<iostream>
#include<iomanip>
using namespace std;
void getInfo(int &sqft,double &price){// //ask a user for the square feet of wall space to be painted and the price of paint per gallon.
cout<<"The 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 ";
cout<<"be required. The company charges $18.00 per hour for labor. ";
cout<<"Enter square feet of wall space: ";
cin>>sqft;
do{
cout<<"Enter price of per gallon paint: ";
cin>>price;
if(price<10){
cout<<"The minimum price is $10 per gallon paint. ";
}
}while(price<10);
}
double ComputePaintCost(double pergallonCost,int sqft){
double gallons=sqft/115;
return gallons*pergallonCost;
}
double ComputeLaborCost(int sqft){
double hours=sqft/8;
return hours*18.00;
}
double ComputeTotalCost(double paintcost,double laborcost){
return paintcost+laborcost;
}
void output(int sqft,double galloncost,double paintcost,double laborcost, double totalcost){
cout<<" Area painted: "<<sqft<<" square feet Price per gallon paint: $"<<galloncost;
cout<<" Paint Cost: $"<<paintcost<<" Labor Cost: $"<<laborcost<<" Total Cost: $"<<totalcost<<endl;
return;
}
int main(){
int sqft;
double pergallonPrice, paintCost,LaborCost,totalCost;
cout<<setiosflags(ios::fixed)<<setprecision(2);
getInfo(sqft,pergallonPrice);
paintCost=ComputePaintCost(pergallonPrice,sqft);
LaborCost=ComputeLaborCost(sqft);
totalCost=ComputeTotalCost(paintCost,LaborCost);
output(sqft,pergallonPrice,paintCost,LaborCost,totalCost);
cin.get();cin.get();
return 0;
}
Explanation / Answer
#include<iostream>
#include<iomanip>
using namespace std;
void getInfo(int *sqft,double *price){// //ask a user for the square feet of wall space to be painted and the price of paint per gallon.
cout<<"The 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 ";
cout<<"be required. The company charges $18.00 per hour for labor. ";
cout<<"Enter square feet of wall space: ";
cin>>sqft;
do{
cout<<"Enter price of per gallon paint: ";
cin>>price;
if(price<10){
cout<<"The minimum price is $10 per gallon paint. ";
}
}while(price<10);
}
double ComputePaintCost(double pergallonCost,int sqft){
double gallons=sqft/115;
return gallons*pergallonCost;
}
double ComputeLaborCost(int sqft){
double hours=sqft/8;
return hours*18.00;
}
double ComputeTotalCost(double paintcost,double laborcost){
return paintcost+laborcost;
}
void output(int sqft,double galloncost,double paintcost,double laborcost, double totalcost){
cout<<" Area painted: "<<sqft<<" square feet Price per gallon paint: $"<<galloncost;
cout<<" Paint Cost: $"<<paintcost<<" Labor Cost: $"<<laborcost<<" Total Cost: $"<<totalcost<<endl;
return;
}
int main(){
int sqft;
double pergallonPrice, paintCost,LaborCost,totalCost;
cout<<setiosflags(ios::fixed)<<setprecision(2);
getInfo(sqft,pergallonPrice);
paintCost=ComputePaintCost(pergallonPrice,sqft);
LaborCost=ComputeLaborCost(sqft);
totalCost=ComputeTotalCost(paintCost,LaborCost);
output(sqft,pergallonPrice,paintCost,LaborCost,totalCost);
cin.get();cin.get();
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.