Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* John J. Scuteri 9/13/2011
- BCS 230 Foundations of Computer Programming
- Assignment # 4 Paint Job Estimation */
- #include <iostream>
- #include <cmath>
- #include <iomanip>
- using namespace std;
- int numRooms();
- int numGals(float);
- float paintPrice();
- float wallArea();
- float laborHrs(float);
- void displayCost(int, float, float);
- int main() {
- float sZ = (wallArea() / 160);
- int pGal = numGals(sZ);
- displayCost(pGal, paintPrice(), laborHrs(sZ));
- return 0;
- }
- int numRooms() {
- int num;
- cout << "Enter the number of rooms : ";
- cin >> num;
- cout << endl;
- return num;
- }
- int numGals(float area) {
- int gal = ceil(area);
- return gal;
- }
- float paintPrice() {
- float cost;
- cout << "What is the price of the paint\n in US dollars. (format 10.00) : ";
- cin >> cost;
- cout << endl;
- return cost;
- }
- float wallArea() {
- float rA = 0;
- int size;
- int i;
- int in = 1;
- i = numRooms();
- while (i >= in) {
- cout << "Enter the the size of room " << in << " : ";
- cin >> size;
- cout << endl;
- rA += size;
- in++;
- }
- return rA;
- }
- float laborHrs(float wallsz) {
- float hrs = (wallsz * 3);
- return hrs;
- }
- void displayCost(int gallons, float pp,float hours) {
- float wC = (hours * 28);
- float pC = (gallons * pp);
- cout << "The number of gallons of paint required ---------- " << gallons << endl;
- cout << "The hours of labor required ---------------------- " << hours << endl;
- cout << "Total cost of paint per Gallon is ----------------$" << fixed << showpoint << setprecision(2) << pp << endl;
- cout << "Total cost of paint ------------------------------$" << fixed << showpoint << setprecision(2) << pC << endl;
- cout << "Total cost of labor ------------------------------$" << fixed << showpoint << setprecision(2) << wC << endl;
- cout << "Total cost of job --------------------------------$" << fixed << showpoint << setprecision(2) << wC + pC << endl;
- }
- /*
- Output From the program below
- -------------------------------------------------------------------------------------------
- Enter the number of rooms : 4
- Enter the size of room 1 : 288
- Enter the size of room 2 : 384
- Enter the size of room 3 : 224
- Enter the size of room 4 : 336
- What is the price of the paint
- in US dollars. (format 10.00) : 25.50
- The number of gallons of paint required ---------- 8
- The hours of labor required ---------------------- 23.1
- Total cost of paint per Gallon is ----------------$25.50
- Total cost of paint ------------------------------$204.00
- Total cost of labor ------------------------------$646.80
- Total cost of job --------------------------------$850.80
- Press any key to continue . . .
- --------------------------------------------------------------------------------------------
- */
Add Comment
Please, Sign In to add comment