Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- double transportationFootprint(double kmPerDay, double fuelEfficiency)
- {
- double litresUsedPerYear = 365 * (kmPerDay / fuelEfficiency);
- double kgCO2 = (2.3 * litresUsedPerYear);
- return kgCO2;
- }
- double electricityFootprint(double kWhPerMonth, int numPeopleInHome)
- {
- double kgCO2 = (kWhPerMonth * 12 * 0.257) / numPeopleInHome;
- return kgCO2;
- }
- double foodFootprint(double meat, double dairy, double fruitVeggies, double carbs)
- {
- double kgCO2;
- double meat_kgCO2 = meat * 53.1;
- double dairy_kgCO2 = dairy * 13.8;
- double fruitVeggies_kgCO2 = fruitVeggies * 7.6;
- double carbs_kgCO2 = carbs * 3.1;
- kgCO2 = meat_kgCO2 + dairy_kgCO2 + fruitVeggies_kgCO2 + carbs_kgCO2;
- return kgCO2;
- }
- double totalFootprint(double transportation, double electricity, double food)
- {
- double kgCO2;
- double tCO2 = (transportation + electricity + food) / 1000;
- kgCO2 = tCO2;
- return kgCO2;
- }
- int main ()
- {
- std::cout << std::fixed;
- std::cout << std::setprecision(2);
- double kmPerDay1;
- double fuelEfficiency1;
- double transportationFootprint1;
- double kWhPerMonth1;
- int numPeopleInHome1;
- double electricityFootprint1;
- double meat_kgCO2;
- double dairy_kgCO2;
- double fruitVeggies_kgCO2;
- double carbs_kgCO2;
- double foodFootprint1;
- double totalFootprint1;
- cout << "How many km do you drive in one day? ";
- cin >> kmPerDay1;
- cout << "What is the fuel efficiency rating of your car? ";
- cin >> fuelEfficiency1;
- transportationFootprint1 = transportationFootprint(kmPerDay1,fuelEfficiency1);
- cout << "Your Carbon footprint with respect to care use is " << transportationFootprint1 << "kg/year" << endl;
- cout << "What is the average electricity consumption per month, in kilowatts? ";
- cin >> kWhPerMonth1;
- cout << "How many people live in the house? ";
- cin >> numPeopleInHome1;
- electricityFootprint1 = electricityFootprint(kWhPerMonth1, numPeopleInHome1);
- cout << "Your Carbon footprint with respect to electricity use is " << electricityFootprint1 << "kg/year" << endl;
- cout << "Of all the food you eat, what percent consists of meat or fish? ";
- cin >> meat_kgCO2;
- cout << "Of all the food you eat, what percent consists of dairy products ";
- cin >> dairy1;
- cout << "Of all the food you eat, what percent consists of fruit and vegetables? ";
- cin >> fruitVeggies_kgCO2;
- cout << "Of all the food you eat, what percent consists of carbohydrates? ";
- cin >> carbs_kgCO2 >> endl;
- foodFootprint1 = foodFootprint(meat_kgCO2, dairy_kgCO2, fruitVeggies_kgCO2, carbs_kgCO2);
- cout << "Your Carbon footprint with respect to food consumption is " << foodFootprint1 << "kg/year" << endl;
- totalFootprint1 = totalFootprint(transportationFootprint1, electricityFootprint1, foodFootprint1);
- cout << "Your produce an annual total of " << totalFootprint1 << " metric tons of CO2 per year." << endl << "All done!";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement