Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- const int MONTHLY_BILL_FOR_WATER = 20;
- const int MONTHLY_BILL_FOR_INTERNET = 15;
- const double OTHER_BILLS_RERCENTAGE = 1.20;
- int months;
- cin >> months;
- double totalElectricityBill = 0, currentElectricityBill;
- for (int i = 0; i < months; i++) {
- cin >> currentElectricityBill;
- totalElectricityBill += currentElectricityBill;
- }
- double totalWaterBill = months * MONTHLY_BILL_FOR_WATER;
- double totalInternetBill = months * MONTHLY_BILL_FOR_INTERNET;
- double totalOtherBills = (totalElectricityBill + totalWaterBill + totalInternetBill) * OTHER_BILLS_RERCENTAGE;
- double average = (totalElectricityBill + totalWaterBill + totalInternetBill + totalOtherBills) / months;
- cout.setf(ios::fixed);
- cout.precision(2);
- cout << "Electricity: " << totalElectricityBill << " lv\n";
- cout << "Water: " << totalWaterBill << " lv\n";
- cout << "Internet: " << totalInternetBill << " lv\n";
- cout << "Other: " << totalOtherBills << " lv\n";
- cout << "Average: " << average << " lv\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement