//Andrew Alspaugh CS1A Chapter 6. P. 374. #17
/****************************************************************************
* Estimate Costs of Painting
* _________________________________________________________________________
* This program calclautes the square feet of a surface that needs to be
* painted. Once the total square feet is calculated, the program estimates
* gallons of paint, hours of labor, and the costs of paint, labor and the total
* cost
* ___________________________________________________________________________
* INPUT USES (SEE DATA DICTIONARY)
* rooms
* roomsArea
* roomsCounter
* gallonPrice
* laborRate
* OUTPUT
* totalArea
* gallonNum
* paintCost
* laborHours
* laborCost
* totalCost
* ***************************************************************************/
#include <iostream>
using namespace std;
//Prototypes
int getNumRooms();
float getArea(int rooms);
float getGallonPrice();
int calculateGallons(float totalArea);
float getPaintCost(int gallonNum, float paintcost);
float getLaborHours (float totalArea);
float getLaborCost (float laborHours, float laborRate);
float getTotalCost (float paintCost, float laborCost);
int main()
{
//DATA DICTIONARY
int rooms; //input //total rooms
float roomsArea = 0; //input //area per room
float totalArea = 0; //output //total square feet
int roomsCounter; //input //counter
float gallonPrice; //input //gallon price
int gallonNum; //output //number of gallons
float paintCost; //output //cost of paint
float laborHours; //output //time of labor
const float laborRate = 18.00; //input //constant labor rate
float laborCost; //output //cost of labor
float totalCost; //output //TOTAL COST
//INPUT
//input rooms
rooms = getNumRooms();
//input area per room and get the total area
totalArea = getArea(rooms);
//input price per gallon
gallonPrice = getGallonPrice();
//PROCESS
//Solve for Required Gallons
// + 1 is required to round up to a whole number of gallons
gallonNum = calculateGallons(totalArea);
//Solve for Paint Cost
paintCost = getPaintCost(gallonNum, gallonPrice);
//Solve for Hours of Labor
laborHours = getLaborHours(totalArea);
//Solve for Labor Cost
laborCost = getLaborCost (laborHours, laborRate);
//Solve for Total Cost
totalCost = getTotalCost (paintCost, laborCost);
//OUTPUT
//display gallons
cout << "You need " << gallonNum << " gallons of paint" << endl << endl;
//display paint cost
cout << gallonNum << " gallons of paint costs $" << paintCost << endl << endl;
//display labor time
cout << "It will take " << laborHours << " hours" << endl << endl;
//display labor cost
cout << "Your Labor Cost Will be $" << laborCost << endl << endl;
//display total cost
cout << "Your total is $" << totalCost << endl;
return 0;
}
// GET NUMBER OF ROOMS
int getNumRooms()
{
int rooms;
cout << "Enter Number of Rooms:" << endl;
cin >> rooms;
cout << "There are " << rooms << " rooms" << endl << endl;
return rooms;
}
//GET SQUARE FEET OF ROOMS AND TOTAL AREA
float getArea(int rooms)
{
float roomsArea = 0;
float totalArea = 0;
for (int roomsCounter = 1; roomsCounter <= rooms; roomsCounter++)
{
cout << "Enter square foot for room # " << roomsCounter << ":" << endl;
cin >> roomsArea;
cout << "This room has " << roomsArea << " square feet" << endl << endl;
totalArea += roomsArea;
}
return totalArea;
}
//Get Price per Gallon
float getGallonPrice()
{
float gallonPrice = 0;
cout << "Enter Cost For Each Gallon of Paint" << endl;
cin >> gallonPrice;
cout << "One Gallon of Paint Costs $" << gallonPrice << endl << endl;
return gallonPrice;
}
//Get Number of Gallons
int calculateGallons(float totalArea)
{return (totalArea / 115) + 1;}
//Get Price of Paint
float getPaintCost(int gallonNum, float gallonPrice)
{return gallonNum * gallonPrice;}
//Get Labor Hours
float getLaborHours (float totalArea)
{return (totalArea / 115) * 8;}
//Get Labor Cost
float getLaborCost (float laborHours, float laborRate)
{return laborHours * laborRate;}
//Get Total Cost
float getTotalCost (float paintCost, float laborCost)
{return paintCost + laborCost;}