Hi all,
Im currently doing an assignment where we have been told to write a program to input 2 values (namely the area of wallspace to be painted & the price of the paint) & then output several other values based on the values input.
At this point I'm writing a function (determineLabourAndPaint) that is going to calculate the litres of paint required & the hours of labour that will be needed to perform the job.
However, I can't get the litres of paint to round up to the next integer value (I've put code in that, according to the textbook, is correct for performing such a task).
The code I've got so far is:
//Assignment 2 Q5a
#include<iostream>
using namespace std;
const int COST_UNIT = 8;
const float LABOUR_FACTOR = 1.5;
const int LABOUR_COST_PER_HOUR = 55;
void inputAndValidate (float & wallSpaceP, float & paintCost)
{
cout << "Enter the WallSpace (in metres squared): ";
cin >> wallSpaceP;
cout << "Enter the price per litre of the paint: ";
cin >> paintCost;
if (paintCost < 20.00)
do
{
cout << "The price per litre of the paint can't be less than R20.00."
<< endl << "Please enter the price again: R";
cin >> paintCost;
}while (paintCost < 20.00);
}
void determineLabourAndPaint (float wallSpaceP, float & hoursLab,
int & litresPaintReq)
{
float paintLitres;
paintLitres = (wallSpaceP / COST_UNIT) ;
litresPaintReq = int (paintLitres + 0.5);
hoursLab = ((wallSpaceP / COST_UNIT) * LABOUR_FACTOR);
}
int main ( )
{
float wallSpace, paintPrice, hrsOfLabour, costOfLabour, costOfPaint,
totalCost;
int litresPaint;
inputAndValidate (wallSpace, paintPrice);
determineLabourAndPaint (wallSpace, hrsOfLabour, litresPaint);
cout.setf(ios::fixed);
cout.precision(2);
cout << "Wall space: " << wallSpace << " square metres\n"
<< "Price of paint: R" << paintPrice << endl
<< "Hours of labour: " << hrsOfLabour << " hours \n"
<< "Litres of paint: " << litresPaint << " litres \n"
<< "Cost of labour: R" << costOfLabour << endl
<< "Cost of paint: R" << costOfPaint << endl
<< "Total cost of paint job: R" << totalCost << endl;
return 0;
}
Can anyone please assist me with just this part of the program??