Answer to Question #275392 in Python for MAX

Question #275392

In order to discourage excess consumption, an electric company charges its customers a lower rate, namely $0.11, for each of the first 250 kilowatt hours, and higher rate of $0.17 for each additional kilowatt hour. In addition, 10% surtax is added to the final bill. Write a program to calculate electric bills given the number of kilowatt hours consumed as input. Use two function declarations: one to compute the amount due without the surtax and one to compute the total due with surtax.


1
Expert's answer
2021-12-04T01:27:16-0500
#include <iostream>


using namespace std;


double ElectricityBillWithoutSurtax(double kilowattHoursConsumed)
{
    return (kilowattHoursConsumed <= 250.0) ? kilowattHoursConsumed * 0.11 : 250.0 * 0.11 + (kilowattHoursConsumed - 250.0) * 0.17;
}


double ElectricityBillWithSurtax(double kilowattHoursConsumed)
{
    return ElectricityBillWithoutSurtax(kilowattHoursConsumed) * 1.1;
}


int main()
{
    double kh;
    cout << "Enter the number of kilowatt hours of electricity that the client has spent.\n";
    cin >> kh;
    cout << "The amount due without the surtax : $" << ElectricityBillWithoutSurtax(kh) << endl;
    cout << "The total due with surtax         : $" << ElectricityBillWithSurtax(kh) << endl;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS