TERM PAPER TELEPHONE DIRECTORY IN C
Document Sample


//telephone billing c++ code
//password is CBSEPORTAL
//Language: C\C++
#include"iostream.h"
#include"graphics.h"
#include"conio.h"
#include"fstream.h"
#include"process.h"
#include"string.h"
#include"stdio.h"
#include "ctype.h"
#include"dos.h"
void cust(void);
void blcnd(void);
void tel_bill(void);
void pwd(void);
void cpwd(void);
void head(void);
void pas(void);
void date(void);
int counter(); //for idno
struct due_date
{
int dd,mm,yy;
}due;
class bill
{
private:
int idxno,k;
// float charg;
char choice,ch1,ch3,che[15];
public:
char s1[15];
float re,cha,rent,charg;
void adcnd();
void vwcnd();
void mdfcnd();
}bil;
class data
{
private:
int dd,mm,yy,ch2,idno,regno,k,idno1,omr,cmr,re,tcharg,cha,ncc;
float oba;
char addr[30],name[20],fname[20],ch1,ch4,c,ch3,ch,mnth[10],s1[15];
long int tel;
public:
data()
{
idno=0;
}
int menu();
void add();
void delt();
void modf();
void view();
void add_bill();
void disp_bill();
void modf_bill();
}dat;
int data::menu()
{
int ch2;
clrscr();
textcolor(YELLOW);
cout<<"\n\t\t*****************************\n";
cout<<"\t\t* MAIN MENU *";
cout<<"\n\t\t*****************************\n";
cout<<"\n\n\t\t1 : CUSTOMER RECORDS";
cout<<"\n\n\t\t2 : BILL CHARGING CONDITIONS";
cout<<"\n\n\t\t3 : TELEPHONE BILL";
cout<<"\n\n\t\t4 : EXIT";
gotoxy(45,23);
cout<<"HELP :";
gotoxy(45,24);
cout<<"ENTER FROM 1 TO 4";
gotoxy(40,14);
cout<<"\n\n\n\t\t\t ENTER THE RIGHT CHOICE : ";
cin>>ch2;
if((ch2<1)||(ch2>4))
{
cout<<"\n\nERROR !!! ENTER ONLY FROM 1 TO 4 ";
delay(2000);
menu();
}
return ch2;
}
void data::add()
{
dat.idno=counter();
do
{
fstream file;
file.open("rs.txt",ios::app|ios::in|ios::out);
clrscr();
cout<<"\n\t\t INDENTITY NO. : "<<++dat.idno;
cout<<"\nENTER THE REGISTRATION NO. :";
cin>>dat.regno;
cout<<"\nENTER THE DATE OF REGISTRATION (dd/mm/yyyy): ";
cin>>dat.dd>>dat.c>>dat.mm>>dat.c>>dat.yy;
cout<<"\nENTER THE NAME OF CUSTOMER : ";
cin.get();
cin.getline(dat.name,20);
cout<<"\nENTER THE FATHER'S NAME : ";
cin.getline(dat.fname,20);
cout<<"\nENTER THE ADDRESS : ";
cin.getline(dat.addr,30);
cout<<"\nENTER THE TELEPHONE NO. : ";
cin>>dat.tel;
do
{
cout<<"\n\nDO YOU WANT TO ENTER ANOTHER RECORD (Y/N) :";
ch1=getche();
ch1=toupper(ch1);
if((ch1!='Y')&&(ch1!='N'))
{
cout<<"\n\nERROR !!! ENTER ONLY Y OR N ";
delay(2000);
}
}while((ch1!='Y')&&(ch1!='N'));
file.write((char*)&dat,sizeof(dat));
file.close();
}
while(ch1=='Y');
do
{
cout<<" \n\nPRESS 'P' FOR GO BACK : ";
ch3=getche();
ch3=toupper(ch3);
}
while(ch3!='P');
cust();
}
void data::delt()
{
int k=1;
char chara;
clrscr();
do
{
data d;
fstream file,temp;
clrscr();
file.open("rs.txt",ios::in); //open in read mode
temp.open("temp.txt",ios::out); //open in write mode
cout<<"\nENTER THE ID NO. OF CUSTOMER : ";
cin>>d.idno;
cout<<"\nENTER THE NAME : ";
cin>>d.name;
do
{
cout<<"\n\nARE YOU SURE YOU WANT TO DELETE THIS RECORD (Y/N) : ";
chara=getche();
chara=toupper(chara);
if((chara!='Y')&&(chara!='N'))
{
cout<<"\n\nERROR !!! ENTER ONLY Y OR N";
delay(2000);
}
}while((chara!='Y')&&(chara!='N'));
if(chara=='Y')
{
file.seekg(0);
file.read((char*)&dat,sizeof(dat));
while(!file.eof())
{
if((strcmp(d.name,name)!=0)||(d.idno!=idno))
{
temp.write((char*)&dat,sizeof(dat));
}
if((strcmp(d.name,name)==0)&&(d.idno==idno))
k=0;
file.read((char*)&dat,sizeof(dat));
}
if(k!=0)
cout<<"\n\n\t\t RECORD DOES NOT FOUND";
else
cout<<"\n\n\t\t RECORD IS DELETED";
file.close();
temp.close();
do
{
cout<<"\n\nDO YOU WANT TO DELETE ANOTHER RECORD (Y/N) : ";
ch3=getche();
ch3=toupper(ch3);
if((ch3!='Y')&&(ch3!='N'))
{
cout<<"\n\nERROR !!! ENTER ONLY Y OR N";
delay(2000);
}
}while((ch3!='Y')&&(ch3!='N'));
}
else
cust();
}while(ch3=='Y');
remove("rs.txt");
rename("temp.txt","rs.txt");
do
{
cout<<"\n\nPRESS 'P' FOR GO BACK : ";
ch3=getche();
ch3=toupper(ch3);
}while(ch3!='P');
cust();
}
void data::modf()
{
clrscr();
data d;
fstream file,temp;
do
{
int k=1;
clrscr();
file.open("rs.txt",ios::in);
temp.open("temp.txt",ios::app);
cout<<"\nENTER THE CUSTOMER ID NO. WHOSE RECORD YOU WANT TO
MODIFY : ";
cin>>d.idno;
file.seekg(0);
file.read((char*)&dat,sizeof(dat));
while(!file.eof())
{
if(d.idno==idno)
{
cout<<"\n*****************************************";
cout<<"\n\n NAME -------: "<<name;
cout<<"\n\n FATHER'S NAME -------: "<<fname;
cout<<"\n\n ADDRESS -------: "<<addr;
cout<<"\n\n TELEPHONE NO. -------: "<<tel;
cout<<"\n\n*****************************************";
cout<<"\n\n ENTER THE RIGHT NAME OF THE CUSTOMER : ";
cin.get();
cin.getline(d.name,20);
cout<<"\n ENTER THE RIGHT FATHER'S NAME : ";
cin.getline(d.fname,20);
cout<<"\n ENTER THE NEW ADDRESS : ";
cin.getline(d.addr,30);
cout<<"\n ENTER THE NEW TELEPHONE NO. : ";
cin>>d.tel;
strcpy(name,d.name);
strcpy(fname,d.fname);
strcpy(addr,d.addr);
tel=d.tel;
k=0;
}//end of if
temp.write((char*)&dat,sizeof(dat));
file.read((char*)&dat,sizeof(dat));
}//end of while
if(k!=0)
cout<<"\n\n\t\t RECORD DOES NOT PRESENT";
do
{
cout<<"\n\nDO YOU WANT TO MODIFY ANY OTHER RECORD (Y/N) : ";
ch3=getche();
ch3=toupper(ch3);
if((ch3!='Y')&&(ch3!='N'))
{
cout<<"\n\nERROR !!! ENTER ONLY Y OR N ";
delay(2000);
}
}while((ch3!='Y')&&(ch3!='N')); //end of do
file.close();
temp.close();
remove("rs.txt");
rename("temp.txt","rs.txt");
}
while(ch3=='Y');
do
{
cout<<"\n\nPRESS 'P' FOR GO BACK : ";
ch3=getche();
ch3=toupper(ch3);
}while(ch3!='P');
cust();
} //end of function
void data::view()
{
char ch5;
clrscr();
cout<<"********************DISPLAY RECORDS**********************\n";
fstream file;
file.open("rs.txt",ios::app|ios::in|ios::out);
file.seekg(0);
file.read((char*)&dat,sizeof(dat));
while(!file.eof())
{
clrscr();
cout<<"\n*****************************************";
cout<<"\n ID NO. OF THE CUSTOMER -------: "<<idno;
cout<<"\n\n REGISTRATION NO. -------: "<<regno;
cout<<"\n\n DATE OF REGISTRATION -------: "<<dd<<c<<mm<<c<<yy;
cout<<"\n\n NAME OF THE CUSTOMER -------: "<<name;
cout<<"\n\n FATHER'S NAME -------: "<<fname;
cout<<"\n\n ADDRESS -------: "<<addr;
cout<<"\n\n TELEPHONE NO . -------: "<<tel;
cout<<"\n*****************************************";
cout<<"\n\nPRESS ANY KEY TO CONTINUE....";
ch5=getche();
file.read((char*)&dat,sizeof(dat));
k=0;
if((ch5>-127)||(ch5<127))
continue;
}
if(k!=0)
cout<<"\n\n\t\t RECORDS DOES NOT FOUND";
file.close();
do
{
cout<<"\n\nPRESS 'P' FOR GO BACK : ";
ch3=getche();
ch3=toupper(ch3);
}while(ch3!='P');
cust();
}
void data::add_bill()
{
float re,cha,tcharg;
int no;
data dd;
bill bl;
do
{
fstream file,temp,f;
temp.open("tel.txt",ios::out|ios::app|ios::in);
file.open("rs.txt",ios::in);
clrscr();
cout<<"\n*************************TELEPHONE
BILL*****************************";
cout<<"\n\nENTER THE ID NO. CORRESPONDING TO WHICH BILL IS
REQUIRED : ";
cin>>no;
/* dd.id=no;
temp.seekg(0);
temp.read((char*)&dd,sizeof(dd));
while(!temp.eof())
{
if(no==id)
{
cout<<"\n BILL HAS ALREADY MADE FOR THIS ID NO.";
exit(0);
}
temp.read((char*)&dd,sizeof(dd));
} */
file.seekg(0);
file.read((char*)&dd,sizeof(dd));
while(!file.eof())
{
if(no==dd.idno)
{
cout<<"\n NAME -------: "<<dd.name;
cout<<"\n FATHER'S NAME -------: "<<dd.fname;
cout<<"\n ADDRESS -------: "<<dd.addr;
cout<<"\n TELEPHONE NO. -------: "<<dd.tel;
}
/* else
{
clrscr();
gotoxy(15,12);
cout<<"THERE IS NO RECORD CORRESPONDING TO THIS INDEX NO. ";
delay(2000);
tel_bill();
}*/
file.read((char*)&dd,sizeof(dd));
}
do
{
cout<<"\n\nENTER FROM WHICH EXCHANGE THE TELEPHONE IS
CONNECTED : ";
cout<<"\n A : RURAL AREA ";
cout<<"\n B : URBAN AREA ";
cout<<"\n ENTER 'a' OR 'b' : ";
ch=getche();
ch=toupper(ch);
if((ch!='A')&&(ch!='B'))
{
cout<<"\n\nERROR !!! ENTER ONLY A OR B ";
delay(2000);
}
}while((ch!='A')&&(ch!='B'));
char cha;
do
{
cout<<"\nARE YOU SURE....? (Y/N): ";
cha=getche();
cha=toupper(cha);
if((cha!='Y')&&(cha!='N'))
{
cout<<"\n\nERROR !!! ENTER ONLY A OR B ";
delay(2000);
}
}while((cha!='Y')&&(cha!='N'));
if(cha=='N')
add_bill();
if(ch=='A')
strcpy(dd.s1,"RURAL AREA");
else if(ch=='B')
strcpy(dd.s1,"URBAN AREA");
f.open("bill.txt",ios::in);
f.seekg(0);
f.read((char*)&bl,sizeof(bl));
while(!f.eof())
{
if(strcmp(bl.s1,dd.s1)==0)
{
dd.re=bl.rent;
dd.cha=bl.charg;
}
f.read((char*)&bl,sizeof(bl));
}
dd.idno=no;
cout<<"\n\nENTER THE OLD BALANCE AMOUNT : ";
cin>>dd.oba;
cout<<"\nENTER THE OPENING METER READING : ";
cin>>dd.omr;
cout<<"\nENTER THE CLOSING METER READING : ";
cin>>dd.cmr;
if(dd.cmr<dd.omr)
{
cout<<"\n\n\tERROR !!!****ENTER THE CORRECT METER READING****";
delay(2000);
add_bill();
}
if(dd.cmr-dd.omr<=75)
dd.ncc=0;
else
dd.ncc=dd.cmr-dd.omr-75;
dd.tcharg=dd.ncc*dd.cha+dd.re+dd.oba;
temp.write((char*)&dd,sizeof(dd));
file.close();
temp.close();
f.close();
do
{
cout<<"\n\nDO YOU WANT TO MAKE BILL FOR ANOTHER RECORD (Y/N) :";
ch1=getche();
ch1=toupper(ch1);
if((ch1!='Y')&&(ch1!='N'))
{
cout<<"\n\nERROR !!! ENTER ONLY Y OR N ";
delay(2000);
}
}while((ch1!='Y')&&(ch1!='N'));
}
while(ch1=='Y');
do
{
cout<<" \n\nPRESS 'P' FOR GO BACK : ";
ch3=getche();
ch3=toupper(ch3);
}while(ch3!='P');
tel_bill();
}
void data::disp_bill()
{
int n;
bill bi;
data dt;
struct date d;
getdate(&d);
dd=d.da_day;
mm=d.da_mon;
yy=d.da_year;
do
{
clrscr();
cout<<"\nENTER THE ID NO. CORRESPONDING TO WHICH BILL IS REQUIRED
: ";
cin>>n;
clrscr();
fstream file,temp,fil;
file.open("rs.txt",ios::in); //open in read mode
file.seekg(0);
file.read((char*)&dt,sizeof(dt));
while((!file.eof()))
{
if(n==dt.idno)
{
cout<<"\n\t\t***************TELEPHONE BILL******************";
gotoxy(60,3);
cout<<"DATE "<<dd<<"/"<<mm<<"/"<<yy;
cout<<"\n\t\t ID NO. OF THE CUSTOMER -------: "<<dt.idno;
cout<<"\n\t\t DATE OF REGISTRATION -------:
"<<dt.dd<<dt.c<<dt.mm<<dt.c<<dt.yy;
cout<<"\n\t\t NAME OF THE CUSTOMER -------: "<<dt.name;
cout<<"\n\t\t FATHER'S NAME -------: "<<dt.fname;
cout<<"\n\t\t ADDRESS -------: "<<dt.addr;
cout<<"\n\t\t TELEPHONE NO . -------: "<<dt.tel;
}
file.read((char*)&dt,sizeof(dt));
}
file.close();
temp.open("tel.txt",ios::in); //open in read mode
temp.seekg(0);
temp.read((char*)&dt,sizeof(dt));
while((!temp.eof()))
{
if(n==dt.idno)
{
cout<<"\n\t\t BILL IS FOR MONTH -------: "<<mm-1;
cout<<"\n\t\t OPENING METER READING -------: "<<dt.omr;
cout<<"\n\t\t CLOSING METER READING -------: "<<dt.cmr;
cout<<"\n\t\t NO. OF CALLS CONSUMED -------: "<<dt.cmr-dt.omr;
cout<<"\n\t\t NO. OF FREE CALLS -------: 75";
cout<<"\n\t\t NET CHARGEABLE CALLS -------: "<<dt.ncc;
cout<<"\n\t\t RENT -------: "<<dt.re;
date();
cout<<"\n\t\t OLD BALANCE AMOUNT -------: "<<dt.oba;
cout<<"\n\t\t TOTAL AMOUNT BEFORE DUE DATE -------: "<<dt.tcharg;
cout<<"\n\t\t SURCHARGE -------: "<<dt.tcharg/10;
cout<<"\n\t\t TOTAL AMOUNT AFTER DUE DATE -------: "<<dt.tcharg*11/10;
if(dt.tcharg>4000)
cout<<"\n\t\t BILL MUST BE PAID EITHER BY D.DRAFT OR BY CHEQUE";
cout<<"\n\t\t\t\tTHANKS";
gotoxy(60,24);
cout<<"______________";
gotoxy(63,25);
cout<<"J.A.O.";
}
temp.read((char*)&dt,sizeof(dt));
}
temp.close();
do
{
cout<<"\nDO YOU WANT TO SEE THE BILL OF ANOTHER CUSTOMER (Y/N) :";
ch1=getche();
ch1=toupper(ch1);
if((ch1!='Y')&&(ch1!='N'))
{
cout<<"\n\nERROR !!! ENTER ONLY Y OR N ";
delay(2000);
}
}while((ch1!='Y')&&(ch1!='N'));
}while(ch1=='Y');
getch();
tel_bill();
}
void data::modf_bill()
{
clrscr();
data d;
fstream temp,f;
do
{
int k=1;
clrscr();
f.open("tel.txt",ios::in);
temp.open("temp.txt",ios::app);
f.seekg(0);
cout<<"\nENTER THE CUSTOMER ID NO. WHOSE RECORD YOU WANT TO
MODIFY : ";
cin>>d.idno;
f.read((char*)&dat,sizeof(dat));
while(!f.eof())
{
if(d.idno==idno)
{
cout<<"\n*****************************************";
cout<<"\n\n\t\t PREVIOUS READINGS ";
cout<<"\n\n OPENING METER READING -------: "<<omr;
cout<<"\n\n CLOSING METER READING -------: "<<cmr;
cout<<"\n\n OLD BALANCE AMOUNT -------: "<<oba;
cout<<"\n\n*****************************************";
cout<<"\n\n ENTER THE RIGHT OPENING METER READING: ";
cin>>d.omr;
cout<<"\n ENTER THE RIGHT CLOSING METER READING : ";
cin>>d.cmr;
if(d.cmr<d.omr)
{
cout<<"\n\n\tERROR !!!****ENTER THE CORRECT METER READING****";
delay(2000);
modf_bill();
}
cout<<"\n ENTER THE RIGHT OLD BALANCE AMOUNT : ";
cin>>d.oba;
omr=d.omr;
cmr=d.cmr;
oba=d.oba;
k=0;
}//end of if
temp.write((char*)&dat,sizeof(dat));
f.read((char*)&dat,sizeof(dat));
}//end of while
if(k!=0)
cout<<"\n\n\t\t RECORD DOES NOT PRESENT";
do
{
cout<<"\n\nDO YOU WANT TO MODIFY ANY OTHER BILL (Y/N) : ";
ch3=getche();
ch3=toupper(ch3);
if((ch3!='Y')&&(ch3!='N'))
{
cout<<"\n\nERROR !!! ENTER ONLY Y OR N ";
delay(2000);
}
}while((ch3!='Y')&&(ch3!='N')); //end of do
f.close();
temp.close();
remove("tel.txt");
rename("temp.txt","tel.txt");
}
while(ch3=='Y');
do
{
cout<<"\n\nPRESS 'P' FOR GO BACK : ";
ch3=getche();
ch3=toupper(ch3);
}while(ch3!='P');
tel_bill();
} //end of function
void bill::adcnd()
{
fstream f;
//int n=0;
f.open("bill.txt",ios::in);
f.seekg(0,ios::end);
if(f.tellg()>0) /*f.tellg() return -1 when file is empty*/
{
clrscr();
gotoxy(20,10);
cout<<"CONDITION HAS ALREADY BEEN ENTERED";
delay(2000);
}
else
{
for(int i=1;i<=2;i++)
{
f.open("bill.txt",ios::in|ios::out|ios::app);
clrscr();
cout<<"\n*********ADDING CHARGING CONDITIONS*********** ";
idxno=i;
cout<<"\n\n*****************************************";
cout<<"\n\n INDEX NUMBER -------: "<<idxno;
if(idxno==1)
strcpy(s1,"RURAL AREA");
else
strcpy(s1,"URBAN AREA");
cout<<"\n\n AREA -------:"<<s1;
cout<<"\n\n\n*****************************************";
cout<<"\n\nENTER THE CHARGE/TELEPHONE CALL : ";
cin>>charg;
cout<<"\n\nENTER THE RENT/MONTH : ";
cin>>rent;
f.write((char*)&bil,sizeof(bil));
f.close();
}
do
{
cout<<" \n\nPRESS 'P' FOR GO BACK : ";
ch3=getche();
ch3=toupper(ch3);
}while(ch3!='P');
}//end of else
blcnd();
}
void bill::vwcnd()
{
clrscr();
fstream f;
f.open("bill.txt",ios::in|ios::out);
f.seekg(0);
f.read((char*)&bil,sizeof(bil));
while(!f.eof())
{
cout<<"\n*****************************************";
cout<<"\n\n INDEX NO. -------: "<<idxno;
cout<<"\n AREA -------: "<<s1;
cout<<"\n CHARGE/TELEPHONE CALL -------: "<<charg;
cout<<"\n RENT/MONTH -------: "<<rent;
cout<<"\n DUE DATE IS 15 DAYS AFTER THE ISSUING DATE OF BILL ";
cout<<"\n SURCHARGE : 10 % OF GROSS AMOUNT ";
cout<<"\n\n\n*****************************************";
f.read((char*)&bil,sizeof(bil));
k=0;
} /*dat.star();*/
if(k!=0)
cout<<"\n\n\t\t RECORDS DOES NOT FOUND";
f.close();
do
{
cout<<"\n\nPRESS 'P' FOR GO BACK : ";
ch3=getche();
ch3=toupper(ch3);
}while(ch3!='P');
blcnd();
}
void bill::mdfcnd()
{
clrscr();
int k=1;
fstream f,t;
bill b;
for(int i=1;i<=2;i++)
{
clrscr();
f.open("bill.txt",ios::in);
t.open("cond.txt",ios::out);
if(i==1)
{
cout<<"\nENTER THE INDEX NO. WHOSE CONDITIONS YOU WANT TO
MODIFY : ";
cout<<"\n\n1 . RURAL AREA\n\n2 . URBAN AREA";
cout<<"\n\n\tENTER YOUR CHOICE : ";
cin>>b.idxno;
}
f.seekg(0);
f.read((char*)&bil,sizeof(bil));
while(!f.eof())
{
if(b.idxno==idxno)
{
clrscr();
cout<<"***************************************************";
cout<<"\n\n INDEX NO. -------: "<<idxno;
cout<<"\n\n AREA -------: "<<s1;
cout<<"\n\n CHARGE/TELEPHONE CALL -------: "<<charg;
cout<<"\n\n RENT/MONTH -------: "<<rent;
cout<<"\n***************************************************";
cout<<"\n\n ENTER THE NEW CHARGES FOR THIS INDEX NO. : ";
cin>>b.charg;
cout<<"\n\n ENTER THE NEW RENT : ";
cin>>b.rent;
charg=b.charg;
rent=b.rent;
k=0;
}
t.write((char*)&bil,sizeof(bil));
f.read((char*)&bil,sizeof(bil));
}
if(i==1)
{
if(b.idxno==1)
b.idxno=2;
else
b.idxno=1;
}
f.close();
t.close();
remove("bill.txt");
rename("cond.txt","bill.txt");
if(k!=0)
{
cout<<"\n\t\t RECORD DOES NOT PRESENT";
break;
}
if(i==1)
{
do
{
cout<<"\n\nDO YOU WANT TO MODIFY SECOND CHARGING CONDITION (Y/N)
: ";
ch3=getche();
ch3=toupper(ch3);
if((ch3!='Y')&&(ch3!='N'))
{
cout<<"\n\nERROR !!! ENTER ONLY Y OR N";
delay(2000);
}
}while((ch3!='Y')&&(ch3!='N'));
}
if(ch3=='Y')
continue;
else
break;
}
do
{
cout<<"\n\nPRESS 'P' FOR GO BACK : ";
ch3=getche();
ch3=toupper(ch3);
}while(ch3!='P');
blcnd();
}
char ch1,ch4,name3[20],desig3[20],pass[20],c,passwd[20];
int ch2,ch5,j=0,k=1,ch3,i;
void main()
{
int driver=DETECT,mode,e,f;
clrscr();
initgraph(&driver,&mode,"");
delay(500);
floodfill(3,3,WHITE);
while(!kbhit())
{
for(int a=1;a<30;a++)
{
clrscr();
setcolor(RED);
if(a>8)
e=8;
else
e=a;
sound(500*a);
settextstyle(7,HORIZ_DIR,e);
moveto(1,1);
outtext("BHARAT");
moveto(100,100);
outtext("SANCHER");
moveto(200,200);
outtext("NIGAM");
moveto(300,300);
outtext("LTD.");
moveto(400,400);
nosound();
delay(80);
}
for(int b=1;b<30;b++)
{
clrscr();
if(b>8)
f=8;
else
f=b;
settextstyle(7,HORIZ_DIR,f);
setcolor(RED);
sound(500*b);
moveto(1,1);
outtext("THE");
moveto(100,100);
outtext("TELEPHONE");
moveto(200,200);
outtext("BILLING");
moveto(300,300);
outtext("SYSTEM");
nosound();
delay(80);
}
}
closegraph();
textcolor(YELLOW);
clrscr();
pas();
getch();
}
void cust()
{
clrscr();
int ch3;
textcolor(3);
cout<<"\n\n\n\t\t*************CUSTOMER RECORD*****************";
cout<<"\n\n\n\t\t 1 : TO ADD NEW RECORD \n";
cout<<"\n\t\t 2 : TO DELETE RECORD \n";
cout<<"\n\t\t 3 : TO MODIFY RECORD \n";
cout<<"\n\t\t 4 : TO VIEW ALL RECORDS \n";
cout<<"\n\t\t 5 : RETURN YO MAIN \n";
gotoxy(45,23);
cout<<"HELP :";
gotoxy(45,24);
cout<<"ENTER FROM 1 TO 5";
gotoxy(40,15);
cout<<"\n\n\n\t\t\t ENTER THE RIGHT CHOICE :";
cin>>ch3;
if((ch3<1)||(ch3>5))
{
cout<<"\n\nERROR !!! ENTER ONLY FROM 1 TO 5 ";
delay(2000);
cust();
}
switch(ch3)
{
case 1:
{
dat.add();
break;
}
case 2:
{
dat.delt();
break;
}
case 3:
{
dat.modf();
break;
}
case 4:
{
dat.view();
break;
}
case 5:
{
textcolor(YELLOW);
head();
}
};
}
void blcnd()
{
int ch3;
clrscr();
cout<<"\n\t\t**************BILLING CONDITION******************";
cout<<"\n\n\t\t 1 : ADDITION OF NEW CHARGE CONDITION ";
cout<<"\n\n\t\t 2 : MODIFICATION ";
cout<<"\n\n\t\t 3 : VIEWING ALL CONDITIONS ";
cout<<"\n\n\t\t 4 : RETURN TO MAIN MENU ";
cout<<"\n\n\t\t\t ENTER YOUR CHOICE FROM ABOVE 1 TO 4 : ";
cin>>ch3;
if((ch3<1)||(ch3>4))
{
cout<<"\n\nERROR !!! ENTER ONLY FROM 1 TO 4 ";
delay(2000);
blcnd();
}
switch(ch3)
{
case 1:
{
bil.adcnd();
break;
}
case 2:
{
bil.mdfcnd();
break;
}
case 3:
{
bil.vwcnd();
break;
}
case 4:
{
textcolor(YELLOW);
head();
}
};
}
void tel_bill()
{
int ch3;
clrscr();
cout<<"\n\t\t************BILLING RECORDS************";
cout<<"\n\n\t\t 1 : MAKING THE BILL ";
cout<<"\n\n\t\t 2 : DISPLAYING BILL ";
cout<<"\n\n\t\t 3 : MODIFY THE BILL ";
cout<<"\n\n\t\t 4 : RETURN TO MAIN MENU ";
cout<<"\n\n\t\t\t ENTER YOUR CHOICE FROM 1 TO 4 : ";
cin>>ch3;
if((ch3<1)||(ch3>4))
{
cout<<"\n\nERROR !!! ENTER ONLY FROM 1 TO 4 ";
delay(2000);
tel_bill();
}
switch(ch3)
{
case 1:
{
dat.add_bill();
break;
}
case 2:
{
dat.disp_bill();
break;
}
case 3:
{
dat.modf_bill();
break;
}
case 4:
{
textcolor(YELLOW);
head();
}
};
}
void head()
{
clrscr();
ch2=dat.menu();
switch(ch2)
{
case 1:
{
textcolor(3);
cust();
break;
}
case 2:
{
textcolor(RED);
blcnd();
break;
}
case 3:
{
textcolor(GREEN);
tel_bill();
break;
}
case 4:
{
exit(0);
}
}//end of switch
}// end of head()
void pas()
{
int ch3;
char pass[15];
clrscr();
gotoxy(30,10);
cout<<"1 : ENTER THE PASSWORD ";
gotoxy(30,12);
cout<<"2 : CHANGE PASSWORD ";
gotoxy(35,14);
cout<<"ENTER YOUR CHOICE 1 OR 2 : ";
cin>>ch3;
if((ch3<1)||(ch3>2))
{
cout<<"\nERROR !!! ENTER ONLY FROM 1 OR 2 ";
delay(2000);
pas();
}
if(ch3==1)
pwd();
else
cpwd();
}
void pwd()
{
int j=0;
char c,pass[20];
clrscr();
gotoxy(30,10);
cout<<"ENTER THE PASSWORD : ";
while(j<15)
{
c=getche();
c=toupper(c);
cout<<"\b";
if(c=='\r')
{
pass[j]='\0';
break;
}
pass[j]=c;
cout<<"*";
j++;
}//end of while
fstream file;
file.open("pwd.txt",ios::in);
file.seekg(0);
file.read((char*)&passwd,sizeof(passwd));
while(!file.eof())
{
file.read((char*)&passwd,sizeof(passwd));
}
file.close();
if(strcmp(pass,passwd)==0)
{
clrscr();
gotoxy(30,12);
cout<<"CORRECT PASSWORD";
gotoxy(20,14);
cout<<"YOU ARE AUTHORISED TO ENTER THE SYSTEM";
delay(2000);
head();
}
else
{
if(i>2)
{
clrscr();
gotoxy(30,12);
cout<<"WRONG PASSWORD";
gotoxy(20,14);
cout<<"YOU ARE NOT AUTHORISED TO ENTER THE SYSTEM";
delay(2000);
exit(0);
}
else
{
clrscr();
gotoxy(20,12);
i++;
cout<<"WRONG PASSWORD..!!! ENTER THE CORRECT PASSWORD";
delay(2000);
pwd();
}//end of else
}//end of else
}
void cpwd()
{
fstream file,tem;
int j=0;
char c,temp[20];
clrscr();
gotoxy(30,10);
cout<<"ENTER THE OLD PASSWORD : ";
while(j<15)
{
c=getche();
c=toupper(c);
cout<<"\b";
if(c=='\r')
{
temp[j]='\0';
break;
}
temp[j]=c;
cout<<"*";
j++;
}//end of while
file.open("pwd.txt",ios::in);
file.seekg(0);
file.read((char*)&passwd,sizeof(passwd));
while(!file.eof())
{
file.read((char*)&passwd,sizeof(passwd));
}
file.close();
if(strcmp(temp,passwd)==0)
{
clrscr();
file.open("pwd.txt",ios::out);
int j=0;
char c,passwd[15],s2[15];
clrscr();
gotoxy(30,10);
cout<<"ENTER THE NEW PASSWORD : ";
while(j<15)
{
c=getche();
c=toupper(c);
cout<<"\b";
if(c=='\r')
{
passwd[j]='\0';
break;
}
passwd[j]=c;
cout<<"*";
j++;
}//end of while
file.write((char*)&passwd,sizeof(passwd));
file.close();
head();
}
else
{
if(i>2)
{
clrscr();
gotoxy(30,12);
cout<<"WRONG PASSWORD";
gotoxy(20,14);
cout<<"YOU ARE NOT AUTHORISED TO ENTER THE SYSTEM";
delay(2000);
exit(0);
}
else
{
clrscr();
gotoxy(20,12);
i++;
cout<<"WRONG PASSWORD..!!! ENTER THE CORRECT PASSWORD";
delay(2000);
cpwd();
}//end of else
}//end of else
getch();
}
int counter()
{
fstream file;
clrscr();
int n=0;
file.open("rs.txt",ios::in);
file.seekg(0,ios::end);
int endposition=file.tellg();
n=endposition/sizeof(data);
if(file.tellg()>0)
{
return n;
}
else
{
return 0;
}
}
void date()
{
int dd,mm,yy;
char c;
struct date d;
getdate(&d);
dd=d.da_day;
mm=d.da_mon;
yy=d.da_year;
if(mm==1||mm==3||mm==5||mm==7||mm==8||mm==10)
{
dd=dd+15;
if(dd>31)
{
dd=dd-31;
mm++;
if(mm>12)
mm=mm-12;
}
}
else if(mm==12)
{
dd=dd+15;
if(dd>31)
{
dd=dd-31;
mm++;
if(mm>12)
mm=mm-12;
yy++;
}
}
else if(mm==4||mm==6||mm==9||mm==11)
{
dd=dd+15;
if(dd>30)
{
dd=dd-30;
mm++;
}
}
else if(mm==2)
{
if(yy%4==0)
{
dd=dd+15;
if(dd>29)
{
dd=dd-29;
mm++;
}
}
else
{
dd=dd+15;
if(dd>28)
{
dd=dd-28;
mm++;
}
}
}
cout<<endl<<"\t\t DUE DATE -------: "<<dd<<"/"<<mm<<"/"<<yy;
}
Related docs
Get documents about "