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.
#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;
}
Comments
Leave a comment