Write a C++ program to input electricity unit charges and calculate the total electricity bill according to the given condition:
For the first 50 units Rs. 0.50/unit
For the next 100 units Rs. 0.75/unit
For the next 100 units Rs. 1.20/unit
For units above 250 Rs. 1.50/unit
An additional surcharge of 20% is added to the bill
#include<iostream>
using namespace std;
int main()
{
float units,totalbill,surcharge;
cout<<"enter your electricity units: ";
cin>>units;
if(units<=50)
units = units*0.50;
else if(units>=51 && units<=150)
units=units*0.75;
else if(units>=151 && units<=250)
units=units*1.20;
else if(units>250)
units=units*1.50;
else
cout<<"you enter invalid units";
cout<<"Your bill is "<<units<<endl;
surcharge=(units*20)/100;
totalbill=units+surcharge;
cout<<"your bill to 20% surcharge is "<<surcharge<<endl;
cout<<"Your bill after surcharge is "<<totalbill;
}
Output: