An electricity board charges the following rates to domestic users to discourage large consumption of energy:
FOR the first 100 units - 60P per unit
For next 200 units - 80P per unit
Beyond 300 units - 90P per unit
All users are charged a minimum of Rs.50.00. if the total amount is more than Rs.300.00 than an additional surcharge of 15% is added Write a C++ program to read the names of users and number of units consumed and print out the charges with names.


Implementation of above problem in C++ language:
#include<iostream.h>
#include<conio.h>
int main()
{
int no_unit;
float charge,scharge;
char name[20];
cout<<”\n enter name and number of units consumed”;
cin>>name;
cin>>no_unit;
if(no_unit<=100)
charge=(0.60*no_unit);
elseif(no_unit>100&&no_unit<=300)
{
charge=(100*0.60);
charge+=((no_unit-100)*0.80);
}
elseif(no_unit>=300)
{
charge=(100*0.60);
charge+=(200*0.80);
charge+=((no_unit-300)*0.90);
}
if(charge<50)
charge=50;
if(charge>300)
{
scharge=(0.15*charge);
charge+=scharge;
}

cout<<”electricity bill \n”;
cout<<name<<” : : rs”<<charge;
getch();
return(0);
}


Thanks
Mukesh Rajput
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

1 comments: