In: Computer Science
A painting company has determined that for every 110 square feet of wall space, one gallon of paint and eight hours of labor will be required. The company charges $25.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 also ask for the square feet of wall space in each room.
It should then display the following data:
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.
C++ Program:
#include <iostream>
using namespace std;
double numGalons(int sqFeet, int rooms){
double numGalons=(sqFeet*rooms)/110;
return numGalons;
}
double hoursLabourRequired(int sqFeet, int rooms){
return ((sqFeet*rooms)/110)*8;
}
double costOfPaint(double numberOfGalons,double pricePerGalon){
return numberOfGalons*pricePerGalon;
}
double labourCharges(double hours){
return hours*25;
}
double totalCost(double labCharge,double costOfPaint){
return labCharge+costOfPaint;
}
int main() {
int sqFeetWallSpace,rooms;
double pricePerGalon,quantity,hours,cost,charges,totalCost1;;
do{
cout<<"Enter number of rooms: ";
cin>>rooms;
}while(rooms<=0);
do{
cout<<"Enter square feet of wall space in each room: ";
cin>>sqFeetWallSpace;
}while(sqFeetWallSpace<0);
do{
cout<<"Enter price price Per Galon of paint ";
cin>>pricePerGalon;
}while(pricePerGalon<10);
quantity=numGalons(sqFeetWallSpace,rooms);
hours=hoursLabourRequired(sqFeetWallSpace,rooms);
cost=costOfPaint(quantity,pricePerGalon);
charges=labourCharges(hours);
totalCost1=totalCost(charges,cost);
cout<<"Number of Galons required: "<<quantity<<endl;
cout<<"Number of hours of work required: "<<hours<<endl;
cout<<"Cost of paint : $"<<cost<<endl;
cout<<"Charges for labour: $"<<charges<<endl;
cout<<"Total cost for paint job: $"<<totalCost1<<endl;
}
if you like the answer please provide a thumbs up.