Sie sind auf Seite 1von 34

COMPUTER SCIENCE PROJECT

ADDRESS BOOK SIRI 2.0

ARPEET SAHOO XII C Roll No: D.A.V. SENIOR SECONDARY SCHOOL,MOGAPPAIR

.: Index :.

1. Certificate......................................................... 1 2. Acknowledgments............................................ 2 3. About The Project.............................................3 4. Concepts Applied.4 5. Source Code.....................................................5 6. Output Screenshots of Major Features.............23

7. Bibliography29

Bonafide Certificate Certified to be the Bonafide Project work in


Science Computer

done by

Arpeet Sahoo

of Class ..Section ......

of .. during the year 2011 to 2012.


Signature of Principal: School Seal: Signature of teacher

.
Designation: PGT / TGT

Submitted for the practical exam held on . at .. Internal Examiner ................................. External Examiner .

Chief Superintendent Date: Page1

.: Acknowledgements :.
2 Teachis 2 Touch lives 4 Ever ~Author Unknown

On this note, I would like to thank our Principal, Smt.LALITHA THIAGARAJAN for her unwavering and whole-hearted support towards completion of this effort. I would like to express my sincere gratitude to my computer science mentor Mrs Uma Arthi, for her vital support, guidance andencouragement - without which this project would not have come forth. Iwould also like to express my gratitude to the staff of the Department of Computer Science at D.A.V Senior Secondary School,Mogappair for their supportduring the making of this project.

Page2

.: About The Project :.


The software ADDRESS BOOK SIRI 2.0is a contacts management software which is suited for a wide range of users end users wanting to keep track of their contacts, corporates who want a management software for their public relations operations, and government administrators who want an easy way to manage large databases. This software is however essentially coded to act as a personal contacts database. To achieve this, the program offers the following different feature sets:

USER FACILITY: The software is capable of handling multiple users by allowing them to access their own personal address books while also ensuring user security and privacy by applying simple username password combinations unique to each user.
MULTIPLE

DIAL CONCEPT: This unique and salient feature of the software is a very original and innovative concept which allows the user to add their most important contacts to their speed dial which enables quick dialing of that number by just pressing the unique code associated with that contact. Quite obviously the software has been designed with a view to be incorporated into mobile phones and other personal devices.
SPEED

CALENDAR: The birthday calendar allows the user to view all contact names whose birthday falls in a specified month. This is another innovative concept which helps the user to greatly enhancepersonal relations by not actually having to remember much!!!
BIRTHDAY

Other than this, the software also implements the standard concepts of database management. ADD CONTACTS EDIT CONTACTS DELETE CONTACTS SEARCH CONTACTS NAME SEARCH ALPHABET SEARCH NUMBER SEARCH DIPLAY CONTACTS
Page3

.:CONCEPTS USED:.

BINARY FILE OPERATIONS

DATA FILE HANDLING DATA STRUCTURES NESTING OF STRUCTURES DATA HIDING

Page4

.: Source Code :.
/* Program Title : Address Book Programmers : ARPEET SAHOO 12C06 ARJUN NAIR 12C04 */ #include<iostream.h> #include<stdio.h> #include<conio.h>

#include<fstream.h> #include<string.h> #include<ctype.h> struct day { int d; int m; int y; }; struct contacts { char name[25]; int age; longpn; char add[50]; charemailadd[25]; daybd; }; //BIRTHDAY

//CONTACTS

struct user { charuname[20]; charpword[20]; }; structsdial { char name[20]; longpno; }; intn,j,x,a,b; charans,use; charch,plog; user u; voidprog() { do { G: clrscr();

//MULTIUSER DATABASE

Page5

//SPEED DIAL

//GLOBAL VARIABLES

//ADDRESS BOOK OPERATIONS

fstream f(u.uname,ios::binary|ios::out|ios::in|ios::app); // GLOBAL FILESTREAM OBJECT cout<<"\n\t\t\t ADDRESS BOOK 2011-2012"; cout<<"\n\t\t\t **********************"; cout<<"\n\t\t\t\t MENU"; cout<<"\n\t\t\t\t ####"; cout<<"\n\n 1.Add new contact"; cout<<"\n\n 2.Edit existing contacts"; cout<<"\n\n 3.Delete Existing contacts"; cout<<"\n\n 4.View existing contacts"; cout<<"\n\n 5.Search existing contacts"; cout<<"\n\n 6.Speed Dial Operations"; cout<<"\n\n 7.Birthday Calendar"; cout<<"\n\n 8.Speed dial"; cout<<"\n\n 9.Exit"; cout<<"\n\n Enter your choice\t"; cin>>ch; switch(ch) { //MAIN MENU

//CHOICE OF OPERATION

case '1': //adding new contact { clrscr(); cout<<"\n\n\t\t APPENDING RECORDS"; cout<<"\n\n\n Enter no. of contacts to be added\t";
Page6

cin>>x; cout<<"\n\n\n Enter contact details"; for(inti=0;i<x;i++) { contacts c; cout<<'\n'; cout<<"\n Name :"; gets(c.name); cout<<"\n Age :"; cin>>c.age; cout<<"\n Phone no.:"; cin>>c.pn; cout<<"\n Address :"; gets(c.add); cout<<"\n Email :"; // X CONTACTS READ

gets(c.emailadd); cout<<"\n Birthday"; A1: cout<<"\n Day :"; cin>>c.bd.d; if(c.bd.d>31) { cout<<"\t Enter valid day"; goto A1; } A2: cout<<"\n Month :"; cin>>c.bd.m; if(c.bd.m>12) { cout<<"\t Enter valid month"; goto A2; } cout<<"\n Year :"; cin>>c.bd.y; f.write((char*)&c,sizeof(c)); } cout<<"\n\n\n\t book\n"; break; }

//VALID DAY

//VALID MONTH

//APPENDING

New contacts have been added to the address

Page7

case '2': {

//editting contacts

clrscr(); cout<<"\t\t [EDITTING] "; ofstreamfoute("edit.dat",ios::binary|ios::out); //LOCAL FILESTREAM OBJECT-EDIT contacts s[500]; inti=0; f.seekg(0,ios::beg); while(f.read((char*)&s[i],sizeof(s[i]))) i++; //RECORD COUNT

X: cout<<"\n\n Enter contact name to be editted\t";

char name[25]; gets(name); int found=0; for(int j=0;j<i;j++) { if(strcmpi(name,s[j].name)==0) { found++; cout<<"\n\n\t NAME :\t"; puts(s[j].name); cout<<"\n\n\t AGE :\t"; cout<<s[j].age; cout<<"\n\n\t PHONE NO.:\t"; cout<<s[j].pn; cout<<"\n\n\t ADDRESS :\t"; puts(s[j].add); cout<<"\n\n\t EMAIL :\t"; puts(s[j].emailadd); cout<<"\n\tBirthday"; cout<<"\n\tDay :\t"; cout<<s[j].bd.d; cout<<"\n\t Month :\t"; cout<<s[j].bd.m; cout<<"\n\t Year :\t"; cout<<s[j].bd.y; getche();
Page8

//NAME MATCH

cout<<"\n\n Enter editted contact details"; //MODIFIED DETAILS READ cout<<'\n'; cout<<"\n\t Name :"; gets(s[j].name); cout<<"\n\t Age :"; cin>>s[j].age; cout<<"\n\t Phone no.:"; cin>>s[j].pn; cout<<"\n\t Address :"; gets(s[j].add); cout<<"\n\t Email :"; gets(s[j].emailadd); cout<<"\n\t Birthday"; cout<<"\n\t Day :"; cin>>s[j].bd.d;

cout<<"\n\t Month :"; cin>>s[j].bd.m; cout<<"\n\t Year :"; cin>>s[j].bd.y; } } if(!found) //INVALID CONTACT NAME { cout<<"\n\nInvalid contact name try again?"; char t; cin>>t; if(t=='y'||t=='Y') goto X; } for(int l=0;l<i;l++) //EDIITED DETAIS WRITTEN { foute.write((char*)&s[l],sizeof(s[l])); } foute.close(); f.close(); remove(u.uname); rename("edit.dat",u.uname); cout<<"\n\n\n\t DONE! EXITTING EDITOR"; break; }
Page9

case '3': {

//Deleting contacts

clrscr(); cout<<"\t\t\n\t\n\t [DELETION] "; ofstreamfout("new.dat",ios::binary|ios::out); // LOCAL FILESTREAM OBJECT-DELETE contacts g[50]; inti=0; f.seekg(0,ios::beg); while(f.read((char*)&g[i],sizeof(g[i]))) i++; Z: char name[20]; //RECORD COUNT

int found=0; cout<<"\n\n Enter contact name to be deleted\t"; gets(name); for(int n=0;n<i;n++) { if(strcmpi(g[n].name,name)==0) //NAME MATCH { found++; for(int k=n;k<i-1;k++) //DELETING g[k]=g[k+1]; } } if(!found) //INVALID CONTACT NAME { cout<<"\n\nInvalid contact name try again?"; char t; cin>>t; if(t=='y'||t=='Y') goto Z; } for(int j=0;j<i-1;j++) { fout.write((char*)&g[j],sizeof(g[j])); } cout<<"\n\n\n\t DONE! EXITTING DELETER";
Page10

fout.close(); f.close(); remove(u.uname); rename("new.dat",u.uname); break; } case '4': { clrscr(); cout<<"\t\t\n\t CONTACTS "; int found=0; //DISPLAY ALL CONTACTS

contacts s; f.seekg(0,ios::beg); while(f.read((char*)&s,sizeof(s))) { found++; cout<<"\n\n\t"<<found; cout<<"\n\n\t NAME :\t"; puts(s.name); cout<<"\n\n\t AGE :\t"; cout<<s.age; cout<<"\n\n\t PHONE NO.:\t"; cout<<s.pn; cout<<"\n\n\t ADDRESS :\t"; puts(s.add); cout<<"\n\n\t EMAIL :\t"; puts(s.emailadd); cout<<"\n\n BIRTHDAY"; cout<<"\n\n\t DAY :\t"; cout<<s.bd.d; cout<<"\n\n\t MONTH :\t"; cout<<s.bd.m; cout<<"\n\n\t YEAR :\t"; cout<<s.bd.y; getche(); }
Page11

// DISPLAY

if(!found) //ADDRESS BOOK EMPTY cout<<"\n\t\t\t\tADDRESS BOOK EMPTY"; break; } case '5': //SEARCH { clrscr(); gotoxy(30,1); cout<<" \n\t\t\t[SEARCHING] "; Y: cout<<"\n\n\n\t 1.NAME/ALPHABET \n\n\t 2.PHONE NUMBER \n\n\n ENTER CHOICE FOR CRITERION OF SEARCH"; char c; cin>>c; f: clrscr();

if(c=='1') // ALPHA/NAME SEARCH { cout<<" \n\n\t 1.NAME \n\t 2.ALPHABET\n\n\tENTER CHOICE"; char n; cin>>n; if(n=='1') //NAME SEARCH { cout<<" \n\n\t ENTER NAME TO BE SEARCHED : "; char name[20]; gets(name); contacts s; while(f.read((char*)&s,sizeof(s))) if(strcmpi(name,s.name)==0) // NAME MATCH { cout<<'\n'; cout<<"\n\n\t NAME :\t"; puts(s.name); cout<<"\n\n\t AGE :\t"; cout<<s.age; cout<<"\n\n\t PHONE NO.:\t"; cout<<s.pn; cout<<"\n\n\t ADDRESS :\t"; puts(s.add); cout<<"\n\n\t EMAIL :\t"; puts(s.emailadd); cout<<"\n\t Birthday";
Page12

cout<<"\n\t Day :\t"; cout<<s.bd.d; cout<<"\n\t Month :\t"; cout<<s.bd.m; cout<<"\n\t Year :\t"; cout<<s.bd.y; getche(); goto B; } } else if(n=='2') //ALPHA SEARCH { cout<<" \n\n\t ENTER ALPHABET TO BE SEARCHED : "; char name; cin>>name; contacts s; while(f.read((char*)&s,sizeof(s)))

{ char t=s.name[0]; t=toupper(t); if(name==s.name[0]||name==t) //ALPHA MATCH { cout<<'\n'; cout<<"\n\n\t NAME :\t"; puts(s.name); cout<<"\n\n\t AGE :\t"; cout<<s.age; cout<<"\n\n\t PHONE NO.:\t"; cout<<s.pn; cout<<"\n\n\t ADDRESS :\t"; puts(s.add); cout<<"\n\n\t EMAIL :\t"; puts(s.emailadd); cout<<"\n\t Birthday"; cout<<"\n\t Day :\t"; cout<<s.bd.d; cout<<"\n\t Month :\t"; cout<<s.bd.m; cout<<"\n\t Year :\t"; cout<<s.bd.y; getche(); } } } else if(f.eof()) //NO MATCH cout<<" \n\n\t RECORD NOT FOUND ";
Page13

else { cout<<"\n\n\t\t INVALID CHOICE TRY AGAIN"; goto f; } } else if(c=='2') //PHONE NUMBER SEARCH { cout<<" \n\n\t ENTER PHONE NUMBER TO BE SEARCHED : "; longpn; cin>>pn; contacts s; while(f.read((char*)&s,sizeof(s))) if(pn==s.pn) // NUMBER MATCH {

cout<<'\n'; cout<<"\n\n\t NAME :\t"; puts(s.name); cout<<"\n\n\t AGE :\t"; cout<<s.age; cout<<"\n\n\t PHONE NO.:\t"; cout<<s.pn; cout<<"\n\n\t ADDRESS :\t"; puts(s.add); cout<<"\n\n\t EMAIL :\t"; puts(s.emailadd); cout<<"\n\t Birthday"; cout<<"\n\t Day :\t"; cout<<s.bd.d; cout<<"\n\t Month :\t"; cout<<s.bd.m; cout<<"\n\t Year :\t"; cout<<s.bd.y; getche(); goto B; } if(f.eof()) { cout<<" \n\t RECORD NOT FOUND "; getche(); goto B; } } else { cout<<"\n\tInvalid choice retry"; getche(); goto Y; } break; } case '6': { charsd; char b; sdial s; charfil[25]; strcpy(fil,u.uname); //SPEED DIAL OPERATIONS // NO MATCH

Page14

// INVALID CHOICE

strcat(fil,"sd"); // UNIQUE BINARY FILE FOR MULTIUSERS do { P: clrscr(); cout<<"\n\n\t\t SPEED DIAL OPERATIONS"; //SPEED DIAL MENU cout<<"\n\n\t 1.ADD NEW \n\t 2.VIEW \n\t 3.REMOVE \n\n\t Enter choice"; cin>>sd; int l=1; if(sd=='1') // ADD SPEED DIAL { ofstreamfout(fil,ios::binary|ios::out|ios::app); // LOCAL FILESTREAM OBJECT-SPEED DIAL ADD clrscr(); cout<<"\t\t\n\t ADD SPEED DIAL "; sdialsd; contacts s; f.seekg(0,ios::beg); char j; int found=0; while(f.read((char*)&s,sizeof(s))) //DISPLAY CONTACTS { found++; cout<<'\n'; cout<<"\n\t NAME :"; puts(s.name); strcpy(sd.name,s.name);
Page15

cout<<"\n\t PHONE NUMBER:"; cout<<s.pn; sd.pno=s.pn; cout<<"\n\n\t Add to speed dial?[y/n]"; cin>>j; if(j=='y'||j=='Y') fout.write((char*)&sd,sizeof(sd)); // ADDING } if(!found) // ADDRESS BOOK EMPTY cout<<"\n\n\t NO CONTACTS"; else cout<<"\n\n\t Specified contacts hav been added to speed dial"; fout.close(); } else if(sd=='2') // VIEW SPEED DIAL

{ ifstream fin(fil,ios::binary|ios::in); // LOCAL FILESTREAM OBJECT-SPEED DIAL VIEW if(!fin) cout<<"\n\n\t No speed dials exist"; else { int found=0; while(fin.read((char*)&s,sizeof(s))) //DISPLAY ALL SPEED DIAL { found++; cout<<"\n\n\t"<<l++<<"\t"<<"Name :\t"<<s.name<<"\n\t\t"<<"Phone number:"<<s.pno; } if(!found) // NO SPEED DIAL cout<<"\n\n\t No speed dials exist"; fin.close(); } } else if(sd=='3') // DELETE SPEED DIAL { char j; ifstream fin(fil,ios::binary|ios::in); // LOCAL FILESTREAM OBJECT-SPEED DIAL DELETE if(!fin) cout<<"\n\n\t No speed dials exist";
Page16

else { int found=0; ofstreamfout("speeddial.dat",ios::binary|ios::out); // LOCAL FILESTREAM OBJECT-SPEED DIAL DELETE while(fin.read((char*)&s,sizeof(s))) { found++; cout<<"\n\n\t"<<l++<<"\t"<<"Name : "<<s.name<<"\n\t\t"<<"Phone number:"<<s.pno; cout<<"\n\n\t Delete from speed dial?[y/n]"; cin>>j; if(j=='y'||j=='Y') {;} else

fout.write((char*)&s,sizeof(s)); } fout.close(); remove(fil); rename("speeddial.dat",fil); cout<<"\n\n\t Specified contacts hav been deleted from speed dial"; } } else { cout<<"\n\n\t INVALID CHOICE TRY AGAIN"; getche(); goto P; } cout<<"\n\n\t Do you want to further access speed dial?"; cin>>b; }while(b=='y'||b=='Y'); break; } case '7': // BIRTHDAY CALENDAR ! { clrscr(); cout<<"\n\n\t\t BIRTHDAY CALENDAR"; int x=0; contacts s[500]; f.seekg(0,ios::beg); while(f.read((char*)&s[x],sizeof(s[x]))) // RECORD COUNT {x++;}
Page17

int month; b: cout<<"\n\n\t ENTER MONTH [1-12]\t"; cin>>month; int e=0; for(int j=0;j<=x;j++) { if(s[j].bd.m==month) // MONTH MATCH cout<<"\n\n\t"<<++e<<"\t"<<"Name :\t"<<s[j].name<<"\n\t\t"<<"Birthday :\t"<<s[j].bd.d<<'/'<<s[j].bd.m<<'/'<<s[j].bd.y; } if(!x) cout<<"\n\t\t\t\tADDRESS BOOK EMPTY";

if(!e) cout<<"\n\n\t\t NO BIRTHDAYS"; cout<<"\n\n\t VIEW ANOTHER MONTH ?"; char g; cin>>g; if(g=='y'||g=='Y') goto b; break; }

// NO MATCH

case '8': // SPEED DIAL { charsd; char b; sdial s; charfil[25]; strcpy(fil,u.uname); strcat(fil,"sd"); // UNIQUE SPEED DIAL BINARY FILE clrscr(); cout<<"\n\n\t\t SPEED DIAL"; ifstream fin(fil,ios::binary|ios::in); // LOCAL FILESTREAM OBJECT-SPEED DIAL VIEW if(!fin) cout<<"\n\n\t File does not exist"; else {
Page18

g: fin.seekg(0,ios::end); long x; x=fin.tellg()/sizeof(sdial);

// RECORD COUNT

cout<<"\n\n\t ENTER SPEED DIAL CODE:\t"; int n; cin>>n; if(n>x) { cout<<"\n\n\t No such speed dial exists"; cout<<"\n\n\t VIEW MORE SPEED DIALS?"; char c; cin>>c; if(c=='y'||c=='Y') goto g;

else goto k; } sdial s; fin.seekg((n-1)*sizeof(s),ios::beg); if(fin.eof()) cout<<"\n\n\t No such speed dial exists"; else { fin.read((char*)&s,sizeof(s)); DISPLAY

// SPEED DIAL

cout<<"\n\n\t"<<n<<"\t"<<"Name :\t"<<s.name<<"\n\t\t"<<"Phone number:"<<s.pno; } cout<<"\n\n\t VIEW MORE SPEED DIALS?"; char c; cin>>c; if(c=='y'||c=='Y') goto g; } k: fin.close(); break; } case '9': //EXIT { cout<<"\n\n\n\n\t\t Exitting address book"; goto H;}
Page19

default: // INVALID CHOICE-MAIN MENU { cout<<"INVALID CHOICE TRY AGAIN"; getche(); goto G; } } //end of switch

B: f.close(); cout<<"\n\n\n\t Do you want to further access the address book?(y/n)\t"; cin>>ans; } while(ans=='y'||ans=='Y'); // END OF ADDRESS BOOK

H: } void main() { clrscr(); textcolor(2); textbackground(0); // MAIN DISPLAY cout<<"\n\n\t\tCOMPUTER SCIENCE PROJECT FOR HALF YEARLY EXAM\n"; cout<<"\n\n\t**************** W E L C O M E ********************\t\t "; gotoxy(13,12); cout<<"************ D A V S C H O O L ****************** " ; gotoxy(25,16); cout<<"A D D R E S S B O O K "; gotoxy(34,20); cout<<" D O N E B Y : "; gotoxy(50,20); cout<<" ARJUN NAIR"; gotoxy(50,22); cout<<" ARPEET SAHOO"; gotoxy(20,25); cout<<" *** PRESS ANY KEY TO CONTINUE***";
Page20

//End of function // MAIN // TEXT GREEN // BACKGROUND BLACK

getch(); clrscr(); do { F: clrscr(); // MULTIUSER FACILITY

cout<<"\n\n\t\t\t PROFILE LOG"; // USER LOGIN cout<<"\n\n\t 1.EXISTING USER \n\t 2.NEW USER\n\t 3.EXIT \n\n\tEnter choice:"; cin>>plog; if(plog=='1') { // EXISTING USER

ifstream fin("users.dat",ios::binary|ios::in); // LOCAL FILESTREAM OBJECT-MULTIUSERS user f; cout<<"\n\n\t Enter username:"; gets(u.uname); cout<<"\n\n\t Enter Password:"; gets(u.pword); int flag=0; while(fin.read((char*)&f,sizeof(f)) && flag==0) { if(strcmpi(u.uname,f.uname)==0 &&strcmpi(u.pword,f.pword)==0) // LOGIN MATCH { cout<<"\n\n\t\t WELCOME BACK "<<u.uname; getche(); prog(); // ADDRESS BOOK ACCESSOR flag++; } } if(!flag) // INVALID USER { cout<<"\n\n\t INVALID LOGIN DATA TRY AGAIN"; getche(); goto F; } }
Page21

else if(plog=='2') // NEW USER { ofstreamfout("users.dat",ios::binary|ios::out|ios::app); // LOCAL FILESTREAM OBJECT-MULTIUSERS cout<<"\n\n\t Enter Username:"; gets(u.uname); cout<<"\n\n\t Enter Password:"; gets(u.pword); fout.write((char*)&u,sizeof(u)); cout<<"\n\n\t Your address book has been created"; getche(); prog(); } else if(plog=='3') // EXIT PROJECT

{ goto L; } else if(plog=='7') // USER DATA RECOVERY ! { ifstream fin("users.dat",ios::binary|ios::in); // LOCAL FILESTREAM OBJECT-MULTIUSERS user f; while(fin.read((char*)&f,sizeof(f))) cout<<"\n\n\t"<<f.uname<<"\n\t"<<f.pword; } else // INVALID LOGIN CHOICE { cout<<"\n\n\t INVALID CHOICE TRY AGAIN"; getche(); goto F; } E: cout<<"\n\n\t Do you want to access another address book?"; cin>>use; } while(use=='y'||use=='Y'); // END OF PROJECT L: cout<<"\n\n\t\t\t HAVE A GOOD DAY"; getche(); } //End of main
Page22

.:Output Screenshots:.

Page24

Page25

Page26

Page27

Page28

.:Bibliography:.

Computer science ncert Class 12 VOLUME 1 -sumita arora Computer science ncert Class 11 -sumita arora CBSE.NIC.IN

Page29

REQUIREMENTS
Operating System: Windows 2000/XP/7 and higher. RAM: 256 Mb and higher. System Memory: 5 Mb and higher. Graphics Requirements: Not Required. Speakers: Not required.

Page30

Das könnte Ihnen auch gefallen