fork download
  1. //Andrew Alspaugh CS1A Chapter 6. P. 374. #17
  2.  
  3. /****************************************************************************
  4.  * Estimate Costs of Painting
  5.  * _________________________________________________________________________
  6.  * This program calclautes the square feet of a surface that needs to be
  7.  * painted. Once the total square feet is calculated, the program estimates
  8.  * gallons of paint, hours of labor, and the costs of paint, labor and the total
  9.  * cost
  10.  * ___________________________________________________________________________
  11.  * INPUT USES (SEE DATA DICTIONARY)
  12.  * rooms
  13.  * roomsArea
  14.  * roomsCounter
  15.  * gallonPrice
  16.  * laborRate
  17.  * OUTPUT
  18.  * totalArea
  19.  * gallonNum
  20.  * paintCost
  21.  * laborHours
  22.  * laborCost
  23.  * totalCost
  24.  * ***************************************************************************/
  25. #include <iostream>
  26. using namespace std;
  27.  
  28. //Prototypes
  29. int getNumRooms();
  30. float getArea(int rooms);
  31. float getGallonPrice();
  32. int calculateGallons(float totalArea);
  33. float getPaintCost(int gallonNum, float paintcost);
  34. float getLaborHours (float totalArea);
  35. float getLaborCost (float laborHours, float laborRate);
  36. float getTotalCost (float paintCost, float laborCost);
  37.  
  38. int main()
  39. {
  40.  
  41. //DATA DICTIONARY
  42. int rooms; //input //total rooms
  43. float roomsArea = 0; //input //area per room
  44. float totalArea = 0; //output //total square feet
  45. int roomsCounter; //input //counter
  46.  
  47. float gallonPrice; //input //gallon price
  48. int gallonNum; //output //number of gallons
  49. float paintCost; //output //cost of paint
  50.  
  51. float laborHours; //output //time of labor
  52. const float laborRate = 18.00; //input //constant labor rate
  53. float laborCost; //output //cost of labor
  54.  
  55. float totalCost; //output //TOTAL COST
  56.  
  57. //INPUT
  58. //input rooms
  59. rooms = getNumRooms();
  60.  
  61. //input area per room and get the total area
  62. totalArea = getArea(rooms);
  63.  
  64. //input price per gallon
  65. gallonPrice = getGallonPrice();
  66.  
  67. //PROCESS
  68.  
  69. //Solve for Required Gallons
  70. // + 1 is required to round up to a whole number of gallons
  71. gallonNum = calculateGallons(totalArea);
  72.  
  73. //Solve for Paint Cost
  74. paintCost = getPaintCost(gallonNum, gallonPrice);
  75.  
  76. //Solve for Hours of Labor
  77. laborHours = getLaborHours(totalArea);
  78.  
  79. //Solve for Labor Cost
  80. laborCost = getLaborCost (laborHours, laborRate);
  81.  
  82. //Solve for Total Cost
  83. totalCost = getTotalCost (paintCost, laborCost);
  84.  
  85.  
  86. //OUTPUT
  87. //display gallons
  88. cout << "You need " << gallonNum << " gallons of paint" << endl << endl;
  89.  
  90. //display paint cost
  91. cout << gallonNum << " gallons of paint costs $" << paintCost << endl << endl;
  92.  
  93. //display labor time
  94. cout << "It will take " << laborHours << " hours" << endl << endl;
  95.  
  96. //display labor cost
  97. cout << "Your Labor Cost Will be $" << laborCost << endl << endl;
  98.  
  99. //display total cost
  100. cout << "Your total is $" << totalCost << endl;
  101.  
  102. return 0;
  103. }
  104.  
  105. // GET NUMBER OF ROOMS
  106. int getNumRooms()
  107. {
  108. int rooms;
  109.  
  110. cout << "Enter Number of Rooms:" << endl;
  111. cin >> rooms;
  112. cout << "There are " << rooms << " rooms" << endl << endl;
  113. return rooms;
  114. }
  115.  
  116. //GET SQUARE FEET OF ROOMS AND TOTAL AREA
  117. float getArea(int rooms)
  118. {
  119. float roomsArea = 0;
  120. float totalArea = 0;
  121.  
  122. for (int roomsCounter = 1; roomsCounter <= rooms; roomsCounter++)
  123. {
  124. cout << "Enter square foot for room # " << roomsCounter << ":" << endl;
  125. cin >> roomsArea;
  126. cout << "This room has " << roomsArea << " square feet" << endl << endl;
  127.  
  128. totalArea += roomsArea;
  129. }
  130. return totalArea;
  131. }
  132.  
  133. //Get Price per Gallon
  134. float getGallonPrice()
  135. {
  136. float gallonPrice = 0;
  137.  
  138. cout << "Enter Cost For Each Gallon of Paint" << endl;
  139. cin >> gallonPrice;
  140. cout << "One Gallon of Paint Costs $" << gallonPrice << endl << endl;
  141.  
  142. return gallonPrice;
  143. }
  144.  
  145. //Get Number of Gallons
  146. int calculateGallons(float totalArea)
  147. {return (totalArea / 115) + 1;}
  148.  
  149. //Get Price of Paint
  150. float getPaintCost(int gallonNum, float gallonPrice)
  151. {return gallonNum * gallonPrice;}
  152.  
  153. //Get Labor Hours
  154. float getLaborHours (float totalArea)
  155. {return (totalArea / 115) * 8;}
  156.  
  157. //Get Labor Cost
  158. float getLaborCost (float laborHours, float laborRate)
  159. {return laborHours * laborRate;}
  160.  
  161. //Get Total Cost
  162. float getTotalCost (float paintCost, float laborCost)
  163. {return paintCost + laborCost;}
Success #stdin #stdout 0.01s 5316KB
stdin
5
1000
300
4592
8923
1210
35.75
stdout
Enter Number of Rooms:
There are 5 rooms

Enter square foot for room # 1:
This room has 1000 square feet

Enter square foot for room # 2:
This room has 300 square feet

Enter square foot for room # 3:
This room has 4592 square feet

Enter square foot for room # 4:
This room has 8923 square feet

Enter square foot for room # 5:
This room has 1210 square feet

Enter Cost For Each Gallon of Paint
One Gallon of Paint Costs $35.75

You need 140 gallons of paint

140 gallons of paint costs $5005

It will take 1114.78 hours

Your Labor Cost Will be $20066.1

Your total is $25071.1