"The best way to cheer yourself up is to try to cheer somebody else up." Mark Twain

Saturday, June 5, 2010

WAP to input the number of units of electricity consumed, calculate and print out the charges.

The Electricity board charges according to the following rates:

For the first 100 units – 40 P per unit ( P -> Paise)
For the next 200 units – 50 P per unit
Beyond 300 units – 60 P per unit
All users are charged meter charge also which is Rs. 50/-

void main()
{
int unit;
float charge;
cout << “\n Enter the no. of units , Electricity Consumed :”;
cin >> unit;
if (unit <= 100 )
charge = 50.0 + 0.4 * unit;
else if(unit<=300)
charge = 50.0 +4.0 * 100 + 0.5 * (unit – 100);
else
charge = 50.0 + 4.0 *100 + 0.5 * 200 + 0.6 *( unit – 300) ;
cout << “n The charges is Rs. “ << charge;
getch();
}


C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off.
Now Playing: Ballade Pour Adeline

About Me

My photo
I m an IT lecturer of a college. I love social-work. I want to do something beneficial for society before dying , that can promote our society, to some extent.