Advertisement
Guest User

Untitled

a guest
Oct 13th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.99 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4.  
  5.  
  6.  
  7. double transportationFootprint(double kmPerDay, double fuelEfficiency)
  8. {
  9.  
  10. double litresUsedPerYear = 365 * (kmPerDay / fuelEfficiency);
  11. double kgCO2 = (2.3 * litresUsedPerYear);
  12. return kgCO2;
  13. }
  14.  
  15. double electricityFootprint(double kWhPerMonth, int numPeopleInHome)
  16. {
  17. double kgCO2 = (kWhPerMonth * 12 * 0.257) / numPeopleInHome;
  18. return kgCO2;
  19. }
  20.  
  21. double foodFootprint(double meat, double dairy, double fruitVeggies, double carbs)
  22. {
  23. double kgCO2;
  24. double meat_kgCO2 = meat * 53.1;
  25. double dairy_kgCO2 = dairy * 13.8;
  26. double fruitVeggies_kgCO2 = fruitVeggies * 7.6;
  27. double carbs_kgCO2 = carbs * 3.1;
  28. return kgCO2;
  29. }
  30.  
  31. double totalFootprint(double transportation, double electricity, double food)
  32. {
  33. double kgCO2;
  34. double tCO2 = (transportation + electricity + food) / 1000;
  35. return kgCO2;
  36. }
  37.  
  38.  
  39. int main ()
  40. {
  41. std::cout << std::fixed;
  42. std::cout << std::setprecision(2);
  43.  
  44. double kmPerDay1;
  45. double fuelEfficiency1;
  46. double transportationFootprint1;
  47.  
  48. double kWhPerMonth1;
  49. int numPeopleInHome1;
  50. double electricityFootprint1;
  51.  
  52. double meat1;
  53. double dairy1;
  54. double fruitVeggies1;
  55. double carbs1;
  56. double foodFootprint1;
  57.  
  58.  
  59. double totalFootprint1;
  60.  
  61.  
  62.  
  63. cout << "How many km do you drive in one day? ";
  64. cin >> kmPerDay1;
  65. cout << "What is the fuel efficiency rating of your car? ";
  66. cin >> fuelEfficiency1;
  67. transportationFootprint1 = transportationFootprint(kmPerDay1,fuelEfficiency1);
  68. cout << "Your Carbon footprint with respect to care use is " << transportationFootprint1 << "kg/year" << endl;
  69.  
  70. cout << "What is the average electricity consumption per month, in kilowatts? ";
  71. cin >> kWhPerMonth1;
  72. cout << "How many people live in the house? ";
  73. cin >> numPeopleInHome1;
  74.  
  75. electricityFootprint1 = electricityFootprint(kWhPerMonth1, numPeopleInHome1);
  76.  
  77. cout << "Your Carbon footprint with respect to electricity use is " << electricityFootprint1 << "kg/year" << endl;
  78.  
  79. cout << "Of all the food you eat, what percent consists of meat or fish? ";
  80. cin >> meat1;
  81. cout << "Of all the food you eat, what percent consists of dairy products ";
  82. cin >> dairy1;
  83. cout << "Of all the food you eat, what percent consists of fruit and vegetables? ";
  84. cin >> fruitVeggies1;
  85. cout << "Of all the food you eat, what percent consists of carbohydrates? ";
  86. cin >> carbs1;
  87.  
  88. foodFootprint1 = foodFootprint(meat1, dairy1, fruitVeggies1, carbs1);
  89.  
  90. cout << "Your Carbon footprint with respect to food consumption is " << foodFootprint1 << "kg/year" << endl;
  91.  
  92. totalFootprint1 = totalFootprint(transportationFootprint1, electricityFootprint1, foodFootprint1);
  93.  
  94. cout << "Your produce an annual total of " << totalFootprint1 << " metric tons of CO2 per year." << endl << "All done!";
  95.  
  96. return 0;
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement