Advertisement
Spocoman

06. Bills

Sep 8th, 2023
832
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     const int MONTHLY_BILL_FOR_WATER = 20;
  7.     const int MONTHLY_BILL_FOR_INTERNET = 15;
  8.     const double OTHER_BILLS_RERCENTAGE = 1.20;
  9.  
  10.     int months;
  11.     cin >> months;
  12.  
  13.     double totalElectricityBill = 0, currentElectricityBill;
  14.  
  15.     for (int i = 0; i < months; i++) {
  16.         cin >> currentElectricityBill;
  17.         totalElectricityBill += currentElectricityBill;
  18.     }
  19.  
  20.     double totalWaterBill = months * MONTHLY_BILL_FOR_WATER;
  21.     double totalInternetBill = months * MONTHLY_BILL_FOR_INTERNET;
  22.     double totalOtherBills = (totalElectricityBill + totalWaterBill + totalInternetBill) * OTHER_BILLS_RERCENTAGE;
  23.     double average = (totalElectricityBill + totalWaterBill + totalInternetBill + totalOtherBills) / months;
  24.  
  25.     cout.setf(ios::fixed);
  26.     cout.precision(2);
  27.  
  28.     cout << "Electricity: " << totalElectricityBill << " lv\n";
  29.     cout << "Water: " << totalWaterBill << " lv\n";
  30.     cout << "Internet: " << totalInternetBill << " lv\n";
  31.     cout << "Other: " << totalOtherBills << " lv\n";
  32.     cout << "Average: " << average << " lv\n";
  33.  
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement