-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain V2.cpp
68 lines (51 loc) · 1.34 KB
/
Main V2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Carbon Footprint Version 2
// Tests: PASSED
#include <iostream>
int main();
double calc_carbon_footprint();
int main() {
double cf{calc_carbon_footprint()};
std::cout << cf;
return 0;
}
double calc_carbon_footprint() {
double elec_bill{};
double gas_bill{};
double oil_bill{};
double milage{};
unsigned int small_flights{};
unsigned int large_flights{};
bool newspaper{false};
bool alu_tin{false};
double cf{};
std::cout << "Enter your monthly electricity bill: ";
std::cin >> elec_bill;
std::cout << "Enter your monthly gas bill: ";
std::cin >> gas_bill;
std::cout << "Enter your monthly oil bill: ";
std::cin >> oil_bill;
std::cout << "Enter your yearly milage: ";
std::cin >> milage;
std::cout << "Enter your yearly number of "
<< "flights (< 4 hours): ";
std::cin >> small_flights;
std::cout << "Enter your yearly number of"
<< "flights (> 4 hours): ";
std::cin >> large_flights;
std::cout << "Do you recycle newspaper? (1 or 0): ";
std::cin >> newspaper;
std::cout << "Do you recycle aluminum and tin? (1 or 0): ";
std::cin >> alu_tin;
cf += (elec_bill + gas_bill) * 105;
cf += oil_bill * 113;
cf += milage * 0.79;
cf += small_flights * 1100;
cf += large_flights * 4400;
if (!newspaper) {
cf += 184;
}
if (!alu_tin) {
cf += 166;
}
return cf;
}