Answer to Question #261047 in C++ for WAB

Question #261047

In order to discourage excess electric consumption, an electrical company charges its customers a lower rate of P75 for the first 250 kilowatt-hours and a higher rate of P85 for each additional kilowatt-hour. In addition, a 10% surtax is added to the final bill. Write a program that calculates the electrical bill given the number of kilowatt-hours consumed as input. At the end, print the number of kilowatt-hours consumed and the computed bill.


1
Expert's answer
2021-11-04T03:50:39-0400
#include <iostream>
using namespace std;


float foo(float n)
{
    float ans;
    if (n < 250)
        ans = n * 0.11;
    else
        ans = 250 * 0.11 + (n - 250) * 0.17;
    return ans;
    
}


float bar(float a)
{
    return foo(a) * 1.1;
}


int main(void)
{
    float n;
    cout << "Enter the amount of electricity consumed : ";
    cin >> n;
    cout << "Total: " << bar(n) << 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