A painting 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 also ask for the square feet of wall space in each room. It should then display the following data:
the number of gallons of paint requird
the hours of labor req
the cost of the paint
the labor charges
total cost of the paint job.
Since I started programming 6wks ago ive had the same problem when tasked with writing a progrm like this. I have trouble picking the right variables and trouble setting up the math in the problems. Im not asking anyone to write this for me but I am asking for some guidance in starting and organizing my programs.
I can actually do everything its asking but whats "throwing me for a loop" is the115sqft, 1 gal of paint, 8 hrs of labor. Im just not sure how to put that in my program the right way.
Area / 115 = one galleon of paint and 8 hours of work.
Get the user to input all the floor space in square feet, add them together, then put the total floor space where I have written "Area". Times the result for galleons and hours required to paint that space... Galleons * price per galleon... And so on.
Ok ive got everything but Im having trouble with function paintpergallon.
// A painting company has determined that for every 115 sqft
// of wall space one gal of paint and eight hours of labor will be required.
// The company charges 18.00 per hour for labor.
#include <iostream>
#include <iomanip>
using namespace std;
// Prototype function
int paintPerGallon(int);
void roomPolicy();
void validateRooms();
// Global constant
const double COMPANY_CHARGES = 18.00;
// Main
int main()
{
int numOfrooms;
double totalSquareFeet = 0; // accumulator for running total
double numOfGallons, hoursOfLabor;
double costOfPaint, totalLabor;
// Call function room policy for the user
roomPolicy();
// Ask user to enter number of rooms to be painted
cout << "Enter the number of rooms to be painted.\n";
cin >> numOfrooms;
// Call function validate rooms for user.
validateRooms();
for (int loop = 1 ; loop <= numOfrooms; loop++)
{
int rooms;
cout << "Enter the square feet for room " << loop << ":" << endl;
cin >> rooms;
totalSquareFeet += rooms;
}
// Format output
cout << fixed << showpoint << setprecision(2);
// Display total square feet
// Call function Paint per gallon
paintPerGallon();
// Calculate number of gallons
numOfGallons = totalSquareFeet / 115;
// Calculate hours of labor
hoursOfLabor = numOfGallons * 8;
// Calculate cost of paint
costOfPaint = paintPerGallon * numOfGallons;
// Calculate total labor
totalLabor = hoursOfLabor * COMPANY_CHARGES;
// Let the user know all totals from the paint job
cout << "Total number of gallons used are " << numOfGallons << "." << endl;
cout << "Total hours of labor are " << hoursOfLabor << "." << endl;
cout << "The total cost of the paint is " << costOfPaint << "." << endl;
cout << "Total labor charges will be " << totalLabor << "." << endl;
return 0;
}
//************************************************************
// paintPerGallon
// Define function paintPerGallon
//************************************************************
int paintPerGallon(int)
{
int paintPerGallon;
cout << "How much is the paint per gallon?\n";
cin >> paintPerGallon;
return paintPerGallon;
}
//***********************************************************
// roomPolicy
// Define function roomPolicy
// Displays a message informing the customer of the minium
// and maxium rooms to be painted.
//***********************************************************
void roomPolicy()
{
cout << "Please be advised that we have a one room \n";
cout << "minimum and a fifty room maximum rooms to be painted.\n";
}
//**************************************************************
// validateRooms
// Task : input validation
// Define function validateRooms
// This function is used to make the user stay within a
// certain range.
//***************************************************************
void validateRooms()
{
int numOfrooms;
while (numOfrooms < 1 || numOfrooms > 50)
{
cout << "Please see our room limit policy!\n";
cin >> numOfrooms;
}
}