Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Project 4: Department of Water and Power Create a C++ program which calculates t

ID: 3662037 • Letter: P

Question

Project 4: Department of Water and Power

Create a C++ program which calculates the cost of a residential or business customer's water and power bill. IN ORDER TO RECEIVE FULL CREDIT, YOU MUST CREATE AND CALL FUNCTIONS WITH PARAMETERS TO SOLVE THIS PROBLEM.

Summarized in the chart below is the cost calculations I want your program to perform.

Department of Water and Power

Tier 1 Rate
(first 10 kilowatt hours used in a month)

DWP CALCULATOR

Please tell me about your water and power usage!
Are you a residential[0] or business[1] customer: 0
Water acre feet used this month: 12.75
Electricity kilowatt hours used this month: 4.75
Residential Customer
5 acre feet of water at Tier 1, 7.75 acre feet of water at Tier 2, 0 acre feet of water at Tier 3
4.75 kilowatts at Tier 1, 0 kilowatts at Tier 2, 0 kilowatts at Tier 3
Your Bill This Month From The Department of Water And Power is $190.08

Please tell me about your water and power usage!
Are you a residential[0] or business[1] customer: 1
Water acre feet used this month: 12.75
Electricity kilowatt hours used this month: 4.75
Business Customer
5 acre feet of water at Tier 1, 7.75 acre feet of water at Tier 2, 0 acre feet of water at Tier 3
4.75 kilowatts at Tier 1, 0 kilowatts at Tier 2, 0 kilowatts at Tier 3
Your Bill This Month From The Department of Water And Power is $282.20

Please tell me about your water and power usage!
Are you a residential[0] or business[1] customer: 0
Water acre feet used this month: 25.00
Electricity kilowatt hours used this month: 31.00
Residential Customer
5 acre feet of water at Tier 1, 15 acre feet of water at Tier 2, 5 acre feet of water at Tier 3
10 kilowatts at Tier 1, 20 kilowatts at Tier 2, 1 kilowatt at Tier 3
Your Bill This Month From The Department of Water And Power is $642.45

Please tell me about your water and power usage!
Are you a residential[0] or business[1] customer: 1
Water acre feet used this month: 25.00
Electricity kilowatt hours used this month: 31.00
Business Customer
5 acre feet of water at Tier 1, 15 acre feet of water at Tier 2, 5 acre feet of water at Tier 3
10 kilowatts at Tier 1, 20 kilowatts at Tier 2, 1 kilowatt at Tier 3
Your Bill This Month From The Department of Water And Power is $952.45

Residential Customers Business Customers Monthly Service Charge
(base charge is charged each month to all customers) Base Charge: $14.95 Base Charge: 19.95 Water Rates Tier 1 Rate
(first 5 acre feet of water used in a month) $7.50 per acre foot of water used $12.00 per acre foot of water used Tier 2 Rate
(next 15 acre feet of water used in a month) $15.00 per acre foot of water used $21.50 per acre foot of water used Tier 3 Rate
(all additional acre feet of water used in a month) $25.00 per acre foot of water used $31.00 per acre foot of water used Power Rates

Tier 1 Rate
(first 10 kilowatt hours used in a month)

$4.50 per kilowatt hour used $7.50 per kilowatt hours used Tier 2 Rate
(next 20 kilowatt hours used in a month) $9.00 per kilowatt hour used $15.00 per kilowatt hours used Tier 3 Rate
(all additional kilowatt hours used in a month) $15.00 per kilowatt hour used $20.00 per kilowatt hours used

Explanation / Answer

Bill.cpp

// Bill.cpp : Defines the entry point for the console application.

#include<iostream>
using namespace std;

//base charges
const double resbaseCharges = 14.95;
const double busbaseCharges = 19.95;
//Water rates
const double wresrateTier1 = 7.50;
const double wresrateTier2 = 15.00;
const double wresrateTier3 = 25.00;
const double wbusrateTier1 = 12.00;
const double wbusrateTier2 = 21.50;
const double wbusrateTier3 = 31.00;
//Power rates
const double presrateTier1 = 4.50;
const double presrateTier2 = 9.00;
const double presrateTier3 = 15.00;
const double pbusrateTier1 = 7.50;
const double pbusrateTier2 = 15.00;
const double pbusrateTier3 = 20.00;

void billCalculate(double usageWater, double usageElec,int customerType);
double calculateWaterBill(double, int);
double calculatePowerBill(double, int);

int main()
{
   int type;
   double usageWater, usagePower;
   cout << "Please tell me about your water and power usage!" << endl;
   cout << "Are you a residential[0] or business[1] customer:";
   cin >> type;
   cout << "Water acre feet used this month:";
   cin >> usageWater;
   cout << "Electricity kilowatt hours used this month :";
   cin >> usagePower;
   billCalculate(usageWater, usagePower, type);
   return 0;
}

void billCalculate(double usageWater, double usagePower, int customerType)
{
   double totalBill = 0, powerBill = 0,waterBill=0;
   if (customerType == 0)
   {
       cout << "Residential Customer" << endl;
   }
   else
   {
       cout << "Business Customer" << endl;
   }
   waterBill = calculateWaterBill(usageWater, customerType);
   powerBill = calculatePowerBill(usagePower, customerType);
   if (customerType == 0)
   {
       totalBill += waterBill + powerBill + resbaseCharges;
   }
   else
   {
       totalBill += waterBill + powerBill + busbaseCharges;
   }
   cout<<"Your Bill This Month From The Department of Water And Power is $"<<totalBill<<endl;
}

double calculateWaterBill(double usageWater, int customerType)
{
   double waterBill = 0;
   double tier1 = 0, tier2 = 0, tier3 = 0;
   if (usageWater <= 5)
   {
       tier1 = usageWater;
   }
   else if (usageWater <= 20)
   {
       tier1 = 5;
       tier2 = usageWater - 5;
   }
   else
   {
       tier1 = 5;
       tier2 = 15;
       tier3 = usageWater - 20;
   }
   if (customerType == 0)
   {
       waterBill = tier1*wresrateTier1 + tier2*wresrateTier2 + tier3*wresrateTier3;
   }
   else
   {
       waterBill = tier1*wbusrateTier1 + tier2*wbusrateTier2 + tier3*wbusrateTier3;
   }
   cout << tier1<<" acre feet of water at Tier 1, ";
   cout << tier2<<" acre feet of water at Tier 2, ";
   cout << tier3<<" acre feet of water at Tier 3" << endl;
   return waterBill;
}

double calculatePowerBill(double usagePower, int customerType)
{
   double powerBill = 0;
   double tier1 = 0, tier2 = 0, tier3 = 0;
   if (usagePower <= 10)
   {
       tier1 = usagePower;
   }
   else if (usagePower <= 30)
   {
       tier1 = 10;
       tier2 = usagePower - 10;
   }
   else
   {
       tier1 = 10;
       tier2 = 20;
       tier3 = usagePower - 30;
   }
   if (customerType == 0)
   {
       powerBill = tier1*presrateTier1 + tier2*presrateTier2 + tier3*presrateTier3;
   }
   else
   {
       powerBill = tier1*pbusrateTier1 + tier2*pbusrateTier2 + tier3*pbusrateTier3;
   }
   cout << tier1<<" kilowatts at Tier 1, ";
   cout << tier2<<" kilowatts at Tier 2, ";
   cout << tier3<<" kilowatts at Tier 3" << endl;
   return powerBill;
}