Guest User

Untitled

a guest
Jan 21st, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. /* John J. Scuteri 9/13/2011
  2. BCS 230 Foundations of Computer Programming
  3. Assignment # 4 Paint Job Estimation */
  4.  
  5. #include <iostream>
  6. #include <cmath>
  7. #include <iomanip>
  8.  
  9. using namespace std;
  10.  
  11. int numRooms();
  12. int numGals(float);
  13. float paintPrice();
  14. float wallArea();
  15. float laborHrs(float);
  16. void displayCost(int, float, float);
  17.  
  18. int main() {
  19. float sZ = (wallArea() / 160);
  20. int pGal = numGals(sZ);
  21. displayCost(pGal, paintPrice(), laborHrs(sZ));
  22. return 0;
  23. }
  24.  
  25. int numRooms() {
  26. int num;
  27. cout << "Enter the number of rooms : ";
  28. cin >> num;
  29. cout << endl;
  30. return num;
  31. }
  32.  
  33. int numGals(float area) {
  34. int gal = ceil(area);
  35. return gal;
  36. }
  37.  
  38. float paintPrice() {
  39. float cost;
  40. cout << "What is the price of the paint\n in US dollars. (format 10.00) : ";
  41. cin >> cost;
  42. cout << endl;
  43. return cost;
  44. }
  45.  
  46. float wallArea() {
  47. float rA = 0;
  48. int size;
  49. int i;
  50. int in = 1;
  51. i = numRooms();
  52. while (i >= in) {
  53. cout << "Enter the the size of room " << in << " : ";
  54. cin >> size;
  55. cout << endl;
  56. rA += size;
  57. in++;
  58. }
  59. return rA;
  60. }
  61.  
  62. float laborHrs(float wallsz) {
  63. float hrs = (wallsz * 3);
  64. return hrs;
  65. }
  66.  
  67. void displayCost(int gallons, float pp,float hours) {
  68. float wC = (hours * 28);
  69. float pC = (gallons * pp);
  70. cout << "The number of gallons of paint required ---------- " << gallons << endl;
  71. cout << "The hours of labor required ---------------------- " << hours << endl;
  72. cout << "Total cost of paint per Gallon is ----------------$" << fixed << showpoint << setprecision(2) << pp << endl;
  73. cout << "Total cost of paint ------------------------------$" << fixed << showpoint << setprecision(2) << pC << endl;
  74. cout << "Total cost of labor ------------------------------$" << fixed << showpoint << setprecision(2) << wC << endl;
  75. cout << "Total cost of job --------------------------------$" << fixed << showpoint << setprecision(2) << wC + pC << endl;
  76. }
  77.  
  78. /*
  79. Output From the program below
  80. -------------------------------------------------------------------------------------------
  81. Enter the number of rooms : 4
  82.  
  83. Enter the size of room 1 : 288
  84.  
  85. Enter the size of room 2 : 384
  86.  
  87. Enter the size of room 3 : 224
  88.  
  89. Enter the size of room 4 : 336
  90.  
  91. What is the price of the paint
  92. in US dollars. (format 10.00) : 25.50
  93.  
  94. The number of gallons of paint required ---------- 8
  95. The hours of labor required ---------------------- 23.1
  96. Total cost of paint per Gallon is ----------------$25.50
  97. Total cost of paint ------------------------------$204.00
  98. Total cost of labor ------------------------------$646.80
  99. Total cost of job --------------------------------$850.80
  100. Press any key to continue . . .
  101. --------------------------------------------------------------------------------------------
  102. */
Add Comment
Please, Sign In to add comment