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

Create a C++ program which calculates the cost of a residential or business cust

ID: 3662029 • Letter: C

Question

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)

CULATOR

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

#include<iostream>
#include<math.h>

using namespace std;
void elec(double w){   // function to calculate and print the electricity consumption
  
if(w>5)
                 {
                        cout<<"5 acre feet of water at Tier 1,";
                      
                        w=w-5;
                        }
                        else { cout<<w<< "acre feet of water at Tier 1,";
                    w=0;}
                      
                      if(w>15)
                 {
                        cout<<"15 acre feet of water at Tier 2,";
                        w=w-15;
                       
                        }
                        else {
                             cout<<w<< "acre feet of water at Tier 2,";
                             w=0;
             
                        }
                     cout<<w<< "acre feet of water at Tier 3"; }
                   

void power(double e){     // function to calculate and print the power consumption
   
if(e>10)
                 {
                        cout<<"10 kilowatts at Tier 1,";
                        e=e-10;
                        }
                        else { cout<<e<< " kilowatts at Tier 1,";
                    e=0;}
                      
                      if(e>15)
                 {
                        cout<<"15 kilowatts at Tier 2,";
                        e=e-15;
                       
                        }
                        else {
                             cout<<e<< " kilowatts at Tier 2,";
                             e=0;
             
                        }
                     cout<<e<< " kilowatts at Tier 3"; }
double residential_consumption(double w,double e){   // function to calculate the electricity &power consumption for residential consumer

double t,s1,d1;
        if(w>5){
                s1=5*7.5;
                w=w-5;}
                else{s1=w*7.5;
                 w=0;}
                 if(w>15){
                          s1=s1+15*15;
                          w=w-15;}
                          else{
                                s1=s1+w*15;
                                w=0;}
                              
                      s1=s1+w*25;
                      if(e>10){
                               d1=10*4.5;
                               e=e-10;
                               }else{
                                     d1=e*4.5;
                                     e=0;}
                        if(e>15){
                                 d1=d1+15*9;
                                 e=e-15;}
                                 else{
                                      d1=d1+e*9;
                                      e=0;}
                                      d1=d1+e*15;
                                      t=s1+d1;
                                      return t;}
double business_consumption(double w,double e){ // function to calculate the electricity &power consumption for businessl consumer

double t,s1,d1;
        if(w>5){
                s1=5*12;
                w=w-5;}
                else{s1=w*12;
                 w=0;}
                 if(w>15){
                          s1=s1+15*21.50;
                          w=w-15;}
                          else{
                                s1=s1+w*21.50;
                                w=0;}
                              
                      s1=s1+w*31;
                      if(e>10){
                               d1=10*7.5;
                               e=e-10;
                               }else{
                                     d1=e*7.5;
                                     e=0;}
                        if(e>15){
                                 d1=d1+15*15;
                                 e=e-15;}
                                 else{
                                      d1=d1+e*15;
                                      e=0;}
                                      d1=d1+e*20;
                                      t=s1+d1;
                                      return t;}
                   
int main(){
    int n;
    double w,e,total;
    cout<<"Please tell me about your water and power usage!"<<endl;
    cout<<"Are you a residential[0] or business[1] customer: ";
    cin>>n;
    cout<<"Water acre feet used this month: ";
    cin>>w;
    cout<<endl;
    cout<<"Electricity kilowatt hours used this month: ";
    cin>>e;
    cout<<endl;

    switch(n)
    {
             case 0:
               cout<<"Residential Customer"<<endl;
                elec(w);
                cout<<endl;
                   power(e);
                   cout<<endl;
                 
                   total= 14.95+residential_consumption(w,e);
                   cout<<"Your Bill This Month From The Department of Water And Power is $"<<total;
                      
                        break;
                      
                        case 1:
               cout<<"Business Customer"<<endl;
                elec(w);
                cout<<endl;
                 power(e);
                 cout<<endl;
                 
                   total= 19.95+business_consumption(w,e);
                   cout<<"Your Bill This Month From The Department of Water And Power is $"<<total;
                        break;
                      
                        }
                  
                        return 0;
                        }