You are on page 1of 27

COMPUTER PROJECT

TOPIC YELLOW PAGES

SESSION
2015-2016

SUBMITTED
BY
BOARD ROLL
NO :

915525X
X

XII-B

CERTIFICATE
This is to certify that Board Roll No.
91552XX of class
'XII- B' has worked under my guidance
and
supervision on this project and has
been
successful in completing it during the
session
2015-2016.

MS.
(Computer
Teacher)

ACKNOWLEDGEMENT
It is my utmost pleasure that I,
ABHINAV DUGGAL of class XII B
have completed the project titled
"YELLOW PAGES: PHONE DIRECTORY"
under the guidance of MS.
(computer teacher) without whom
completing
this project would not have been
possible.

ABHINAV
DUGGAL
XII B

SYNOPSIS

This project is all about the most


familiar
Telephone directory "YELLOW PAGES"
which is
an insight into the world of contacts.
With the help of this software,
one can add, delete, modify, view, and
search data.

APPLICATION
AREAS

It is a very useful software which can


be used anywhere
One feels like. For example,

Schools
MNCs
Residential communities
Colleges
Offices
etc.

SCOPE OF THE
PROJECT

This project allows the user to do


various operations
in a telephone directory. It is very easy
to handle, and
simple to work on.
One can add contacts, delete them as
per the requirement,
modify them upto the needs, search
them using various
criteria and also view them all if
required.
It is a robust software that tries to
tackle all
errors or mistakes commited
unintentionally
by the user.

DATA DICTIONARY
USER DEFINED FUNCTIONS
Functions included in this project are:

addition()
Delete()
menu()
search()
view1()
init()
display()
view()
test()
modification()
check()

CLASSES DEFINED
Single class DIRECTORY has been
defined which deals with all the users
information like name, occupation,
E-mail address etc. and moreover also
contains various functions like
addition, deletion, search, view etc.

HEADER FILES USED

fstream.h
conio.h

ctype.h
process.h
iomanip.h
stdio.h
string.h
stdlib.h

USER MANUAL
HARDWARE REQUIREMENTS

MONITOR
KEYBOARD
C.P.U.
MOUSE
PENTIUM 4 PROCESSOR

PRINTER
128MB RAM
GRAPHICS CARD

SOFTWARE REQUIREMENTS

TURBO C++
WINDOWS XP/VISTA/7/8

MENU CHOICES & ACTIONS


ADDITION-- adds any contact to the
phonebook.
DELETION-- delete any contact from
the phonebook.
SEARCH--search any contacts
information stored in the
phonebook as per users choice.

VIEW--view any contacts


information the user wants.
MODIFICATIONmake changes in
persons details like e-mail address,
occupation, phone numbers, etc.

PROGRAM CODING
/*
Language : C++
Description: YELLOW PAGES
*/
#include<fstream.h>
#include<conio.h>
#include<ctype.h>
#include<process.h>
#include<iomanip.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<dos.h>
void welcome_screen();
void login();
//****************************
//FUNCTION FOR THE MAIN SCREEN
//****************************
void welcome_screen()
{
clrscr();
int li,sr[80],dr[80],lp;
//window(1,1,80,50);

sr[0]=1;dr[0]=1; // THE MAIN LOGIC !!


for(li=10;li<71;li++)
{
gotoxy(li,15);
delay(30);
cout<<"\/";
}
for(li=70;li>=10;li--)
{
gotoxy(li,22);
delay(30);
cout<<"\\";
}
for(lp=16;lp<=21;lp++)
{
gotoxy(10,lp);
delay(100);
cout<<"-";
}
for(lp=21;lp>=16;lp--)
{
gotoxy(70,lp);
delay(100);
cout<<"=";
}
gotoxy(16,17);
cout<<"WELCOME TO YELLOW PAGES: TELEPHONE MANAGEMENT SYSTEM";
gotoxy(36,28);
cout<<"\n\t\tCoded By";
gotoxy(32,30);
cout<<"\tABHINAV";
gotoxy(34,48);
cout<<"\n\t\tPress Any Key To ..........Continue";
getch();
login();
}
//*********************
//FUNCTION FOR PASSWORD
//*********************
void login ()
{
G:
clrscr();
char user[10],pass[10],c;
int i=0;
gotoxy(20,20);
cout<<"ENTER THE DETAILS BEFORE USING THE SYSTEM";
gotoxy(25,30);
cout<<"\nUSERNAME : ";
gotoxy(25,32);
cout<<"\nPASSWORD : ";
gotoxy(37,30);
gets(user);

gotoxy(37,32);
c=getch();
while(c!='\r')
{
cout<<"*";
pass[i]=c;
i++;
c=getch();
}
pass[i]='\0';
gotoxy(22,35);
if(strcmp(user,"ABHINAV")==0 && strcmp(pass,"DUGGAL")==0)
{
cout<<"\nSuccessful Login!!!!";
getch();
i=1;
}
else
{
cout<<"INCORRECT PASSWORD!!! TRY AGAIN";
goto G;
}
}
//**************
//THE MAIN CLASS
//**************
class directory
{
public:
int record;
long pn1;
char pn2[10];
int age;
char address1[50];
char address2[50];
char occupation[20];
char name[20];
char emailadd[25];
void modification();
void addition();
void Delete();
void menu();
void search();
void search_name();
void search_email();
void view1();
void init();
void display();
void view();
char check(char *);
int test();
}obj;

//*******************************
//FUNCTION TO FIND NO. OF RECORDS //SEARCH-to write so open in ifstream
//*******************************
int directory::test()
{
ifstream fin;
fin.open("new");
fin.seekg(0,ios::end);
int n;
n=fin.tellg()/sizeof(obj); //eg the byte no of last word is 100
cout<<" \n NUMBER OF RECORDS = "<<n ;
return n ;//storage place
}
//********************************
//FUNCTION TO SEARCH BY NAME
//********************************
void directory::search_name()
{
clrscr();
ifstream fin;
fin.open("new");
if(fin.fail())
//returns nonzero(true) when an input or output operation has failed
//if(fin.fail()=if(!fin)
{
cout<<" \n FILE NOT FOUND ";
getch();
return;
}
clrscr();
gotoxy(30,4);
cout<<" ^-^-^-^-^-SEARCHING^-^-^-^-^ ";
cout<<" \n ENTER the name TO BE SEARCHED : ";
char name1[30];
gets(name1);
int n;
n=test();//n=no of records
for(int i=0;i<n;i++)
{
fin.read((char*)&obj,sizeof(obj)); //writing all the records in the file
if(strcmpi(obj.name,name1)==0)
{
view1();
return;
}
}
if(fin.eof())
{
cout<<" \n RECORD NOT FOUND ";
}
}
//**********************************
//FUNCTION TO SEARCH BY EMAIL

//**********************************
void directory::search_email()
{
clrscr();
ifstream fin;
fin.open("new");
if(fin.fail())
//returns nonzero(true) when an input or output operation has failed
//if(fin.fail()=if(!fin)
{
cout<<" \n FILE NOT FOUND ";
getch();
return;
}
clrscr();
gotoxy(30,4);
cout<<" ^-^-^-^-^-SEARCHING^-^-^-^-^ ";
cout<<" \n ENTER the Email TO BE SEARCHED : ";
char email1[50];
gets(email1);
int n;
n=test();//n=no of records
for(int i=0;i<n;i++)
{
fin.read((char*)&obj,sizeof(obj)); //writing all the records in the file
if(strcmpi(obj.emailadd,email1)==0)
{
view1();
return;
}
}
if(fin.eof())
{
cout<<" \n RECORD NOT FOUND ";
}
}
//******************************************
//FUNCTION TO SEARCH FOR A PARTICULAR NUMBER
//******************************************
void directory::search()
{
clrscr();
ifstream fin;
fin.open("new");
if(fin.fail())
//returns nonzero(true) when an input or output operation has failed
//if(fin.fail()=if(!fin)
{
cout<<" \n FILE NOT FOUND ";
getch();
return;
}
clrscr();
gotoxy(30,4);

cout<<" ^-^-^-^-^-SEARCHING^-^-^-^-^ ";


cout<<" \n ENTER PHONE NUMBER TO BE SEARCHED : ";
long pn;
cin>>pn;
int n;
n=test();//n=no of records
for(int i=0;i<n;i++)
{
fin.read((char*)&obj,sizeof(obj)); //writing all the records in the file
if(pn==pn1)
{
view1();
return;
}
}
if(fin.eof())
{
cout<<" \n RECORD NOT FOUND ";
}
}
//***************************
//FUNCTION TO ADD INFORMATION
//***************************
void directory::addition()//addition->write in the file so ofstream
{
clrscr();
char cc;
do
{
ofstream fout;
fout.open("new",ios::out|ios::app);//app is an output mode which creates
//if it doesn't exist,if exist then existing contents are retainded
//it lets you add data at the end of the file
init();//enter the details
fout.write((char*)&obj,sizeof(obj));//enter details write in the file
fout.close();
cout<<"\n\nDO YOU WANT TO ENTER MORE RECORDS:";
cin>>cc;
}
while(cc=='y'||cc=='Y');
getch();
}
//*************************
//FUNCTION TO ENTER DETAILS
//*************************
void directory::init()
{
clrscr();
char ch;
gotoxy(30,4);
cout<<" ^-^-^-^-^ADDITION^-^-^-^-^ ";
cout<<" \n ENTER HOUSE PHONE NUMBER : ";
cin>>pn1;
cout<<" \n ENTER OFFICE PHONE NUMBER : ";

cin>>pn2;
cin.get(ch);
cout<<" \n ENTER NAME : ";
cin.getline(name,20,'\n');
cout<<" \n ENTER THE OCCUPATION : ";
cin.getline(occupation,20,'\n');
cout<<" \n ENTER HOUSE ADDRESS : ";
cin.getline(address1,50,'\n');
cout<<" \n ENTER OFFICE ADDRESS : ";
cin.getline(address2,50,'\n');
cout<<" \n ENTER EMAIL ADDRESS : ";
cin.getline(emailadd,25,'\n');
getch();
}
//*******************************************************
//FUNCTION TO MODIFY ANY DATA IN THE RECORD IF NECESSARY
//*******************************************************
void directory::modification()
{
clrscr();
int flag=0;
gotoxy(30,4);
cout<<"^-^-^-^-^-MODIFICATION^-^-^-^-^ ";
long pn;
int n,i;
ifstream fin;
ofstream fout;
fin.open("new");
if(fin.fail())
{
cout<<"\n FILE NOT FOUND !";
fout.close();
exit(-1);
}
fout.open("temp");
n=test();
if(n==0)//no record found
{
cout<<"\n FILE IS EMPTY ! ";
getch();
return;
}
while(fin.good())
{
fin.read((char*)&obj,sizeof(obj));
fout.write((char*)&obj,sizeof(obj));
}
fin.close();
fout.close();
fout.open("new",ios::trunc);//pre-existing file is deleted
fin.open("temp");
if(fin.fail())
{
cout<<"\n FILE NOT FOUND !";

exit(-1);
}
char ch;
cout<<"\n ENTER PHONE NUMBER WHOSE DETAILS ARE TO BE MODIFIED :";
cin>>pn;
ch=cin.get();
for(i=0;i<n;i++)
{
fin.read((char*)&obj,sizeof(obj));
char d;
if(pn==pn1)
{
flag=1;
view1();
d=check("HOUSE PHONE NUMBER ");
if((d=='y') || (d=='Y'))
{
cout<<"\n ENTER NEW HOUSE PHONE NUMBER :";
cin>>pn1;
ch=cin.get();
}
if(check("OFFICE PHONE NUMBER ")=='y')
{
cout<<"\n ENTER NEW OFFICE PHONE NUMBER :";
cin>>pn2;
ch=cin.get();
}
if(check("NAME")=='y')
{
cout<<"\n ENTER NEW NAME
: ";
cin.getline(name,20,'\n');
}
if(check("HOME ADDRESS")=='y')
{
cout<<"\n ENTER NEW ADDRESS
:";
cin.getline(address1,50,'\n');
}
if(check("OFFICE ADDRESS")=='y')
{
cout<<"\n ENTER NEW ADDRESS
:";
cin.getline(address2,50,'\n');
}
if(check("EMAIL ADDRESS:")=='y')
{
cout<<"\n ENTER NEW MAIL ADDRESS
:";
cin.getline(emailadd,25,'\n');
}
}
fout.write((char*)&obj,sizeof(obj));
}
if(flag==1)
cout<<"\n\n\n\tModification complete.Press any key to continue.....";
else
cout<<"\n\n\n\tRecord not found \n Press any key to continue...";

getch();
fout.close();
fin.close();
}
//***************************************************
//FUNCTION TO CHECK OPTION TO BE MODIFIED IN A RECORD
//***************************************************
char directory::check(char *s)
{
cout<<"\n MODIFY \t "<<s<<"\t"<<"Y/N";
char ch;
ch =getch();
if((ch=='y')||(ch=='Y'))
return 'y';
else
return 'n';
}
//*****************************
//FUNCTION TO DELETE ANY RECORD
//*****************************
void directory::Delete()
{
clrscr();
//window(1,1,80,25);
textcolor(BLACK);
gotoxy(30,4);
cout<<"^-^-^-^-^-DELETION^-^-^-^-^-^";
long pn;
int n,i;
ifstream fin;
ofstream fout;
fin.open("new");
if(fin.fail())
{
cout<<"\n FILE NOT FOUND ! ";
getch();
return;
}
fout.open("temp");
n=test();
if(n==0)
{
cout<<"\n FILE IS EMPTY ! ";
getch();
return;
}
for(i=0;i<n;i++)
{
fin.read((char*)&obj,sizeof(obj));
fout.write((char*)&obj,sizeof(obj));
}
fin.close();
fout.close();

fout.open("new",ios::trunc);
fin.open("temp");
if(fin.fail())
{
cout<<"\n FILE NOT FOUND ! ";
getch();
return;
}
cout<<"\n ENTER PHONE NUMBER TO BE DELETED :";
cin>>pn;
int flag=0;
for(i=0;i<n;i++)
{
fin.read((char*)&obj,sizeof(obj));
if(pn!=pn1)
fout.write((char*)&obj,sizeof(obj));
else
flag=1;
}
if(flag==1)
cout<<"\n\n\n\tDeletion done \n Press any key to continue...";
else
cout<<"\n\n\n\tRecord not found \n Press any key to continue...";
getch();
fout.close();
fin.close();
}
//************************************************
//FUNCTION TO DISPLAY ALL THE ENTERIES IN A RECORD
//************************************************
void directory::view1()
{
cout<<"\n";
cout<<" HOUSE PHONE NUMBER : "<<obj.pn1<<"\n";
cout<<" OFFICE PHONE NUMBER : "<<obj.pn2<<"\n";
cout<<" NAME
: "<<obj.name<<"\n";
cout<<" HOUSE ADDRESS
: "<<obj.address1<<"\n";
cout<<" OCCUPATION
: "<<obj.occupation<<"\n";
cout<<" OFFICE ADDRESS
: "<<obj.address2<<"\n";
cout<<" EMAIL ADDRESS
: "<<obj.emailadd<<"\n";
cout<<" \n\n\nPress any key to continue...";
getch();
}
//***************************
//FUNCTION TO VIEW ANY RECORD
//***************************
void directory::view()
{
ifstream fin;
int n,j;
fin.open("new");
if(fin.fail()||fin.bad())
{

cout<<"\n FILE NOT FOUND ! ";


getch();
return;
}
clrscr();
int i=0;
n=test();
for(j=0;j<n;j++)
{
cout<<"\n\n\n--------- RECORD "<<i+1<<"------------\n";
fin.read((char*)&obj,sizeof(obj));
cout<<"\n HOUSE PHONE NUMBER :"<<obj.pn1<<"\n";
cout<<"\n OFFICE PHONE NUMBER :"<<obj.pn2<<"\n";
cout<<"\n NAME
:"<<obj.name<<"\n";
cout<<"\n HOUSE ADDRESS
:"<<obj.address1<<"\n";
cout<<"\n OCCUPATION
:"<<obj.occupation<<"\n";
cout<<"\n OFFICE ADDRESS
:"<<obj.address2<<"\n";
cout<<"\n EMAIL ADDRESS
: "<<obj.emailadd<<"\n";
i+=1;
}
fin.close();
cout<<"\n\n\nPress any key to continue...";
getch();
}
//**************************
//FUNCTION FOR THE MAIN MENU
//**************************
void directory::menu()
{
char ch;
clrscr();
gotoxy(23,8);
cout<<"^^^^^^^^^^MAIN MENU^^^^^^^^^^^^^\n";
//gotoxy(30,16);
cout<<" A:ADDITION\n ";
//gotoxy(30,18);
cout<<" D:DELETION\n";
//gotoxy(30,20);
cout<<" M:MODIFICATION\n";
//gotoxy(30,22);
cout<<" V:VIEW\n";
//gotoxy(30,24);
cout<<" S:SEARCH BY PHONE NO\n";
//gotoxy(60,26);
cout<<" N:SEARCH BY NAME\n";
//gotoxy(80,28);
cout<<" L:Search By Email\n";
//gotoxy(60 , 20);
cout<<" E:EXIT\n";
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n" ;
cout<<" ENTER YOUR CHOICE :";
//gotoxy(48,30);
ch=getch();

switch(ch)
{
case 'a':
case 'A':
addition();
break;
case 'd' :
case 'D' :
Delete();
break;
case 'm':
case 'M':
modification();
break;
case 'v':
case 'V':
view();
break;
case 's':
case 'S':
search();
break;
case 'N':
case 'n':
search_name();
break;
case 'l':
case 'L':
search_email();
break;
case 'e':
case 'E':
system("cls");
exit(0);
}
}
void main()
{
welcome_screen();
for(;;)
obj.menu();
}

OUTPUT

You might also like