#include<iostream.h>
#include<conio.h>
class board
{
float Totcost;
int unit;
char name[20];
public:
void accept(void);
void display();
};
void board ::accept(void)
{
cout<<"\n\nEnter the user name : ";
cin>>name;
cout<<"\n\nEnter number of units consumed by user : ";
cin>>unit;
}
void board::display()
{
float cost;
Totcost=150;
if(unit<=100)
{
Totcost=Totcost+(unit*0.40);
}
else if( unit>100 && unit<=300)
{
Totcost=Totcost+(100*0.40)+((unit-100)*0.50);
}
else if(unit>300)
{
Totcost=Totcost+(100*0.40)+(200*0.50)+((unit-300)*0.60);
}
if( Totcost>250)
{
Totcost = Totcost + (Totcost*0.15);
}
cout<<"\n\nUser Name : "<<name;
cout<<"\n\nNumber of units consumed by user : "<<unit;
cout<<"\n\nTotal Charges : "<<Totcost;
}
int main()
{
int n;
board b[10];
clrscr();
cout<<"\n\nEnter how many records you want to enter : ";
cin>>n;
for(int i=0;i<n;i++)
{
b[i].accept();
}
for(i=0;i<n;i++)
{
b[i].display();
}
getch();
return(0);
}

Post a Comment

Previous Post Next Post