fork download
  1. //OrinTill Qimid CS1A Chapter 4, P. 294, 4
  2. //
  3. /**************************************************************
  4.  * CALCULATE ANNUAL POPULATION
  5.  *
  6.  * ____________________________________________________________
  7.  * This program will calculate the annual population per year.
  8.  * ____________________________________________________________
  9.  * INPUT
  10.  * Rooms : howmany room there is
  11.  * charge : how much the paint cost
  12.  *
  13.  * OUTPUT
  14.  * total : the total expense.
  15.  **************************************************************/
  16. #include <iostream>
  17. #include <iomanip>
  18. #include <cmath>
  19. using namespace std;
  20. float paint();
  21.  
  22.  
  23. int main()
  24. {
  25.  
  26. paint();
  27.  
  28. }
  29.  
  30. float paint()
  31. {
  32. // 115 for 1 gallo && 8 hour labor
  33. float gallon,
  34. labor,
  35. rooms,
  36. space,
  37. charge,
  38. paintexpense,
  39. laborcharge,
  40. hours,
  41. number_of_paint,
  42. total;
  43. labor = 18.0;
  44. cout<<"How many rooms would you like to paint?"<<endl;
  45. cin>>rooms;
  46. cout<<"How much for each gallon of paint?"<<endl;
  47. cin>>charge;
  48.  
  49. for (int i = 1; i <= rooms; i++)
  50. {
  51. cout<<"How many squre feet in room "<<i<<" ?"<<endl;
  52. cin>>space;
  53. paintexpense = charge/115;
  54. hours = (8/115)*space;
  55. laborcharge = (labor/115)*18;
  56. number_of_paint = space /115;
  57. total = paintexpense + laborcharge + number_of_paint;
  58.  
  59. }
  60. cout<<"The number of gallons of paint required : "<<number_of_paint<<endl;
  61. cout<<"The hours of labor required : "<<hours<<endl;
  62. cout<<"The cost of the paint : "<<paintexpense<<endl;
  63. cout<<"The labor charges : "<<laborcharge<<endl;
  64. cout<<"The total cost of the paint job : "<<total<<endl;
  65. return total;
  66.  
  67.  
  68. }
  69.  
  70.  
  71.  
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
Standard output is empty