#include
using namespace std;
class ebbill
{
public:
int lread,cread,cmode,tread,diff;
float amt;
char cname[20],mode[];
//public:
void getdata();
float bill(int lread,int cread,int cmode);
void display();
/* ebbill()
{
lread=0;
cread=0;
cmode=0;
}
~ebbill()
{
lread=0;
cread=0;
cmode=0;
}*/
};
void ebbill::getdata()
{
//float amt;
//int diff;
cout<<"Enter the name of the customer : ";
cin>>cname;
cout<<"Enter the customer mode : "<
get:
cout<<"Enter the last month reading : ";
cin>>lread;
cout<<"Enter the current month reading : ";
cin>>cread;
tread=cread-lread;
if (tread<0)
{
cout<<"Enter the correct reading : ";
goto get;
}
diff=tread;
amt=bill(lread,cread,cmode);
display();
}
float ebbill::bill(int lread,int cread,int cmode)
{
float read=0.0;
switch(cmode)
{
case 1:
{
strcpy(mode,"Home");
if ((tread==0)(tread<=100))
read=tread*0.4;
else if (tread<=200)
{
tread=tread-100;
read=(tread*0.75)+40.00;
}
else if (tread<=500)
{
tread=tread-200;
read=(tread*1.5)+(100.00*0.75)+40.00;
}
else
{
tread=tread-500;
read=(tread*2.0)+(300.0*1.5)+75.0+40.0;
}
break;
}
case 2:
{
strcpy(mode,"Business");
if ((tread==0)(tread<=100))
read=tread*1.0;
else if (tread<=500)
{
tread=tread-100;
read=(tread*2.0)+100.00;
}
else
{
tread=tread-500;
read=(tread*5.0)+(400.0*2.0)+100.0;
}
break;
}
case 3:
{
strcpy(mode,"Industry");
if ((tread==0)(tread<=200))
read=tread*5.0;
else if (tread<=1000)
{
tread=tread-200;
read=(tread*5.0)+500.00;
}
else
{
tread=tread-1000;
read=(tread*7.5)+(800.0*5.0)+500.0;
}
break;
}
}
return read;
}
void ebbill::display()
{
cout<<"Customer Name : "<
main()
{
system("clear");
ebbill eb;
eb.getdata();
return 0;
}
No comments:
Post a Comment