Q.32. An electricity board charges the following rates to domestic users to discourage large
consumption of electricity :
1st 100 units
75 P/unit
Next 200 units Rs. 1.50/unit
Beyond 300 units Rs.3/Unit
If the bill is above Rs. 1000 upto Rs. 2000 an extra surcharge of 10% is added. If bill
mount is above Rs. 2000 a surcharge of 20% is added.
write a java program for this.
Attachments:
Answers
Answered by
2
Answer:
include<iostream.h>
#include<conio.h>
class electricity
{
char name[20];
int unit;
float Rs;
public:
void get()
{
cout<<“\nEnter the Name & Unit’s of Electricity user: \n”;
cin>>name>>unit;
}
void check()
{
if(unit<=100)
{
Rs=unit*0.40;
Rs=Rs+150;
}
else if(unit<=200||unit>100)
{
Rs=unit*0.50;
Rs=Rs+150;
}
else if(unit<=300||unit>200)
{
Rs=unit*0.60;
Rs=Rs+150;
}
}
void disp()
{
if(Rs>=250)
{
Rs=Rs+0.15;
}
cout<<name<<” \t”<<Rs<<endl;
}
};
void main()
{
int n,i;
electricity e[10];
clrscr();
cout<<“\nHow many electricity User: \n”;
cin>>n;
for(i=0;i<n;i++)
{
e[i].get();
e[i].check();
}
cout<<“\nElectricity User’s: \n”;
cout<<“\nName\t Total cost(Rs)\n”;
cout<<“=================================\n”;
for(i=0;i<n;i++)
{
e[i].disp();
}
getch();
}
Explanation:
i hope it is a correct answer
Similar questions