//Eric Bernal CS1A Chapter 6, P. 374, #17
//
/*******************************************************************************
* CALCULATE PAINT JOB PRICE ESTIMATOR
*______________________________________________________________________________
* This program calculates the total estimated price of a paint job based off of
* a given number of rooms, square footage of wallspace per room, labor hours,
* labor cost per hour, cost of paint, and number of gallons of paint used.
* _____________________________________________________________________________
* INPUT
* numRooms : The number of rooms to be painted.
* pricePerGallon : The price of paint per gallon.
* sqftPerRoom : The square footage of wallspace to be painted per
* room
* OUTPUT
* numGallon : The number of paint gallons required for this job
* paintCost : The total cost of the required amount of paint
* hours : The number of hours this job will demand
* laborCost : The total cost of labor per hour for this job
* totalCost : The total cost of everything.
* *****************************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
// Global Constants Variables
const float HOURLY_LABOR_WAGE = 18; //Labor cost per hour
const int SQFT_COVERED_BY_ONE_GALLON = 115; //Wallspace a gallon covers
const int HOURS_OF_WORK_PER_ONE_GALLON = 8; //Hours needed to use a gallon
// Function Prototypes:
int numPaintGallons(int numRooms, int sqftPerRoom);
int laborHoursRequired(int numGallonsPaintUsed);
int main() {
// DATA DICTIONARY
int numRooms; //INPUT - Number of rooms to be painted
float pricePerGallon; //INPUT - Price per one gallon of paint
int sqftPerRoom; //INPUT - Wallspace painted per room
float numGallonsNecessary; //OUTPUT - Gallons required for this job
float paintCost; //OUTPUT - Price of required paint amount
float hoursWorked; //OUTPUT - Required number of hours of labor
float laborCost; //OUTPUT - Price of the labor required
float totalCost; //OUTPUT - Total price of this job
//Gather and validate input
do
{
cout << "Enter the number of rooms that need to be painted (must be at"
<< " least one room): ";
cin >> numRooms;
cout << numRooms << endl;
}
while(numRooms <= 1);
do
{
cout << "Enter the price per gallon of paint (must be at least $10): ";
cin >> pricePerGallon;
cout << pricePerGallon << endl;
}
while(pricePerGallon <= 10);
do
{
cout << "Enter the square footage of the wall space per room that must"
<< " be painted (must be a positive integer): ";
cin >> sqftPerRoom;
cout << sqftPerRoom << endl;
}
while(sqftPerRoom < 0);
cout << endl;
//Paint calculations
numGallonsNecessary = numPaintGallons(numRooms, sqftPerRoom);
paintCost = numGallonsNecessary * pricePerGallon;
//Labor calculations
hoursWorked = laborHoursRequired(numGallonsNecessary);
laborCost = hoursWorked * HOURLY_LABOR_WAGE;
//Total cost calculation
totalCost = paintCost + laborCost;
//Display Output
cout << "Gallons of paint required: " << numGallonsNecessary << " Gallons"
<< endl;
cout << "Total labor hours required: " << hoursWorked << " Hours" << endl;
cout << fixed << showpoint << setprecision(2);
cout << "Cost of paint: $" << paintCost << endl;
cout << "Cost of labor: $" << laborCost << endl;
cout << "Total job cost: $" << totalCost << endl;
return 0;
}
/*******************************************************************************
* This function calculates the number of gallons of paint necessary to complete
* this job, given the number of rooms and the wall square footage per room that
* is to be painted.
* ****************************************************************************/
int numPaintGallons(int numRooms, int sqftPerRoom)
{
int sqftOfNeededCoverage; //The total square footage of coverage required
sqftOfNeededCoverage = numRooms * sqftPerRoom;
return ((static_cast<float>(sqftOfNeededCoverage) / SQFT_COVERED_BY_ONE_GALLON) + 1);
}
/*******************************************************************************
* This function calculates the number of hours of labor necessary to complete
* this job, given the number of gallons that must be used.
* ****************************************************************************/
int laborHoursRequired(int numGallonsPaintUsed)
{
return HOURS_OF_WORK_PER_ONE_GALLON * numGallonsPaintUsed;
}