#include <iostream.h>
class bill
{
char name[50];
int unit, p_unit, c_unit;
float price_unit, tbill, tax;
public:
bill()
{
price_unit=3.80;
}
void setname()
{
cout<<"Enter customar name: ";
gets(name);
}
void setunits()
{
again:
cout<<"Enter previous units: ";
cin>>p_unit;
cout<<"Enter current units: ";
cin>>c_unit;
if(c_unit<p_unit)
{
cout<<"Enter Valid data(Units)."<<endl;
goto again;
}
unit=c_unit-p_unit;
}
void make_bill()
{
float temp;
if(unit<=100)
{
temp=price_unit*unit;
tax=(temp*8)/100;
tbill=temp+35+tax;
}
else if(unit>100 && unit<=200)
{
temp=unit*(price_unit+3);
tax=(temp*12)/100;
tbill=temp+35+tax;
}
else
{
temp=unit*(price_unit+6);
tax=(temp*14)/100;
tbill=temp+35+tax;
}
}
void display_bill()
{
int counter=0, i;
for(i=1; i<=4; i++)
{
cout<<"***********************************"<<endl;
counter++;
if(counter==2)
{
cout<<"Name: "<<name<<endl;
cout<<"Your total units are: "<<unit<<endl;
cout<<"You total bill is: R.s "<<tbill<<endl;
}
}
}
void detail()
{
if(unit<=100){price_unit=3.80;}
else if(unit>100 && unit<=200){price_unit=6.80;}
else{price_unit=9.80;}
cout<<"Total Units consumed: "<<unit<<endl;
cout<<"PTV fee: R.s 35"<<endl;
cout<<"Price Per unit at "<<unit<<" units is"<<price_unit<<endl;
cout<<"Tax: "<<tax<<endl;
}
};
main()
{
char a, d;
bill c;
next:
c.setname();
c.setunits();
c.make_bill();
c.display_bill();
cout<<"Press \"D\" or\"d\" to get detail of you bill"<<endl;
cin>>d;
if(d=='D' ||d=='d')
{
c.detail();
}
cout<<"You want to calculate bill of next customar? Y/N ";
cin>>a;
if(a=='y' ||a=='Y')
{
cout<<"***********************************"<<endl;
goto next;
}
}