1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
//Necessary information:
// - 115ft of wall = 8 hours of labor = 1 gallon of paint
// - $18 per 1 hour of labor
//Painting Program
void displayInstructions();
float computePaint(int area, float gallon);
float computeLabor(int area);
float computeTotal(float paint, float labor);
void outputResults(int area, float paint, float labor, float total);
int main()
{
displayInstructions();
return 0;
}
void displayInstructions()
{
int area;
float gallon, total, paint, labor;
//Starting program
cout << "****************************************************" << endl;
cout << "Welcome to the paint calculator" << endl;
cout << "Input: square feet, cost of paint per gallon" << endl;
cout << "Output: paint cost, labor cost ($18 per hour), total cost" << endl;
cout << "****************************************************" << endl;
cout << endl;
//Start asking for variables
cout << "How many square feet of wall space is to be covered? " << endl;
cin >> area;
cout << endl;
cout << "What is the cost of the paint per gallon? " << endl;
cin >> gallon;
paint = computePaint(area, gallon);
labor = computeLabor(area);
total = computeTotal(paint, labor);
outputResults(area, paint, labor, total);
}
float computePaint(int area, float gallon)
{
float paint = (area/115) * gallon;
return paint;
}
float computeLabor(int area)
{
float labor = ((area/115) * 8) * 18;
return labor;
}
float computeTotal(float paint, float labor)
{
float total = paint + labor;
return total;
}
void outputResults(int area, float total, float paint, float labor)
{
cout << setprecision(2) << fixed << endl;
cout << left;
cout << setw(15) << "Square Feet:" << area << endl;
cout << setw(15) << "Paint Cost:" << "$" << paint << endl;
cout << setw(15) << "Labor Cost:" << "$" << labor << endl;
cout << setw(15) << "Total Cost;" << "$" << total << endl;
cout << endl;
}
|