You are on page 1of 1

//Program to Prepare Electricity Bill #include<fstream.h> #include<conio.

h> //for getch() struct consumer { int consumerno; int billno; char billdate[10]; char name[30]; char address[30]; int prevreading; int newreading; }; void main() { ifsteam infile; consumer c; infile.open("electric.dat"); infile.read((char*) &c, sizeof(c)); while(!infile.eof()) { cout<<"\nBill No:"<<c.billno; cout<<"\tBilldate:"<<c.billdate<<endl; cout<<"\nConsumer No:"<<c.consumerno; cout<<"\tName:"<<c.name; cout<<"\nResident of: "<<c.address<<endl; cout<<"\Previous meter reading:"<<c.prevreading; cout<<"\nN w meter reading:"<<c.newreading; int units; units=c.newreading-c.prevreading; float amt1; if(units<=100) amtl=units*2.75; else if(units<=250) amtl=275.0+(150-units)*3.15; else amtl=275.0+472.5+(units-250)*3.90; float mrent=125.0; float amt=amtl+mrent; cout<<"\nUnits consumed:"<<units; cout<<"\nAmount:"<<amtl; cout<<"\nMeter Rent:"<<mrent; cout<<"\nAmount payable:"<<amt; float pd=amt+(amt*10.0\100); cout<<"\nPayment after due date"<<pd; getch(); //pause for a key press infile.read((char*) &c, sizeof(c)); } infile.close(); }