Answer to Question #143050 in C++ for Bunny

Question #143050
VIn order to discourage excess consumption, an electric company charges it's costumers 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 the 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
2020-11-09T00:11:23-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