You are on page 1of 30

COMPUTER

PROJECT

VANSHIKA UNIYAL

12th D
Introduction

My address book software is very easy to use. It's a simple, straight forward
program that allows you to store addresses and print address books more.

Easy Address Entry


All entries are listed alphabetically. Easily add new names, addresses, phone
numbers, emails and notes.

More Features in Address Manager

● Import Addresses
Stop re-typing! Import addresses from Outlook, and other software programs
using a comma delimited file.

● Reports
Create reports of any info you've entered. Great for printing your own Address
Book or Phone Book for a handy reference next to your phone or for your day
planner.

● Change Address Placement
This is a nice option if you have custom address labels with a logo or picture.
You can re-position where the address prints to accommodate your custom
label.
● Search

Search function will search your address entries and display a list of any
entries found that contain your search criteria.

● Thousands of Addresses
● You can add over 25,000 addresses in our address book software.
This software is perfect if you just want to keep track of family
and friends but also designed to be powerful enough for
businesses to maintain large client and customer databases. It's
flexible too.... allowing you to organize your contacts in
categories that you create! You can print personal phone-books,
maintain contact histories, sort your file, maintain database it's
all up to you!
The system provides you with encryption facility to secure your
data.
CERTIFICATE

Certified that this Project belongs to


Roll No.......................................................................................Class 12 th D
Session 2008-2009 of Central Board of Secondary Education

Corresponding to School
DELHI PUBLIC SCHOOL DWARKA

This Project have been done by Vanshika Uniyal and the signatures
affixed on recorded experiments are genuine.

................................
Teacher- Incharge

Countersigned by...........................

Date..................................
HEADER FILES

Header files contain function definition for functions used in the


programme.

These files are loaded in the memory during programme compiling.

Included header files are:


1. fstream.h
This header is included to do file operation in the programme.

2. conio.h
Used for clrscr() function.

3. process.h
Used for exit(int) function.

4. stdio.h
Used for gets() function, which excepts string from user.

5. string.h
Used for strlen() function which returns length of string.
IMPORTANT FUNCTIONS

1. deleate()
This Function enables user to delete fields from the database, it
provides user with option to search the field by Name, Phone
Number, Address, ID.

2. modification()
Enables user to modify required field and modifying rows of user’s
choice.

3. view()
Displays the record of pointed object.

4. search()
Enables searching by Name, Phone Number, Address, ID.

5. modipass()
Enables User to modify master password.

6. sort()
Sorts database according to user’s choice.

7. addition()
Add fields to the database.
SOURCE CODE

#include <fstream.h>
#include <conio.h>
#include <process.h>
#include <stdio.h>
#include <string.h>
void intro();
char u;
int x = 0;
char p[100], pc[100];
int i;
void intro()
{
clrscr();
cout << "\n A D D R E S S B O O K";
cout << "\n\nThis Software can be used in place of your address book.............\nCode "
"Lines::852";
cout << "\n\n\n Used Header Files:---\n1. fstream.h\n2. conio.h\n3. process.h\n4. "
"iomanip.h\n5. stdio.h\n6. string.h\n7. stdlib.h\n";
cout << "\n\n\n\n Coded By----->>>";
cout << "\n\n\n VANSHIKA UNIYAL\n Delhi Public School";
cout << "\n\n <<<Press any Key to continue>>>";
getch();
return;
}
class file
{
int file;
long ph1;
char ph2[10];
int age;
int check(char*);
int count();
char address1[50];
char address2[50];
char occupation[20];
char name[20];
char id[25];
char intdd[25];

public:
void modification();
void addition();
void deleate();
void menu();
void search();
void view1();
void init();
void display();
void view();
void totaldis();
void delbyname();
int submenu();
char* rna();
char* radd();
char* reid();
long rph();
} obj;

char* file::rna() // RETURNS NAME


{
return name;
}
char* file::radd() // RETURNS ADDRESS
{
return address1;
}
char* file::reid() // RETURNS INTERNET ID
{
return intdd;
}
long file::rph() // RETURNS PHONE NUMBER
{
return ph1;
}

char* decode(char* in) // PASAWORD DECODER


{
cout << "\n\nDecoding String..........Decoded..\n";
getch();
char out[100];
int i = 0, n = 0, a = 0;
a = strlen(in);
for (i = 0; i < a; i++)
{
n = in[i];
n = n + 25;
out[i] = n;
n = 0;
}
out[a] = '\0';
return out;
}

void file::totaldis() // TO DISPLAY INTERNAL CONTENT


{
clrscr();
cout << "\n This DISPLAY is For DEBUGGING.....\n\n";
cout << "\nFile: ";
cout << file;
cout << "\nPhone No. 1: ";
cout << ph1;
cout << "\nPhone Number 2: ";
puts(ph2);
cout << "\nge: ";
cout << age;
cout << "\nintdd: ";
puts(intdd);
getch();
}

void first() // PASSWORD CREATION


{
ofstream f1("data1", ios::binary);
l:
cout << "\nEnter New Master Password: ";
gets(p);
int i = 0, n = 0, a;
cout << "\nConfirm New Master Password: ";
gets(pc);
if (!strcmp(p, pc))
{
cout << "\n\nEncrypting Password.....Writing To Disk...";
cout << "\n\n\nData Now Secure....";
a = strlen(p);

for (i = 0; i < a; i++)


{
n = p[i];
n = n - 25;
p[i] = n;
n = 0;
}

f1.write((char*)&p, sizeof(p));
f1.close();
}
else
{
cout << "Entered Password donot match to earlie password, enetr new password..";
goto l;
}
}

int acc() // ACCESS CONTROL


{
int i, u = 3, t = 0;
char mp1[100], mp2[100];
ifstream f2("data1", ios::binary | ios::nocreate);
char mpd[100];
if (f2.good())
{
f2.read((char*)&mp2, sizeof(mp2));
k:
cout << "\nEnter Master Password: ";
gets(mp1);
if (!(strcmp(mp1, decode(mp2))))
{
cout << "\n\nAccess Granted";
getch();
return 1;
}
if (u != 0)
{
cout << "\nWrong password...(" << u << ")";
u--;
goto k;
}
if (u == 0)
{
cout << "3 Attempts Over...";
getch();
}
}
return 0;
}

void pass() // PASSWORD CHECK


{
clrscr();
fstream f1("data1", ios::binary | ios::in | ios::out | ios::nocreate);
if (!f1.good())
{
first();
}
cout << "\n";
int n;
if (acc() == 1)
{
obj.menu();
}
f1.close();
getch();
}

void file::addition() // ADDING INFORMATION


{
char u;
ofstream f1;
f1.open("data.abk", ios::out | ios::app);
init();
f1.write((char*)&obj, sizeof(obj));
f1.close();
cout << " \n\n\n Back To Main Menu(y/n)::: ";
cin >> u;
if ((u == 'y') || (u == 'Y'))
menu();
}
int file::count() // FIND NO. OF RECORDS
{
ifstream f2("data.abk", ios::binary);
int i = 0;
while (f2.read((char*)&obj, sizeof(obj)))
{
i++;
}
cout << " \n\n\n\n\n Number of Records = " << i;
return i;
}
int file::submenu() // SUB MENU OF PROGRAMES
{
char w;
cout << "\n\n\MENU->\n\n";
cout << " \n1.By Name";
cout << " \n2.By Phone Number";
cout << " \n3.By Address";
cout << " \n4.By Internet ID";
cout << " \n5.Back To main Menu";
cout << "\n\nEnter Choice: ";
cin >> w;
int l = 0;
switch (w)
{
case '1':
l = 1;
break;
case '2':
l = 2;
break;
case '3':
l = 3;
break;
case '4':
l = 4;
break;
default:
l = 0;
menu();
}
return l;
}

void file::search() // SEARCHING


{
ifstream f3("data.abk", ios::binary);
if (f3.fail())
{
cout << " \n File Not Found!!!! ";
getch();
return;
}

long pn;
char na[50], add[50], eid[50];
clrscr();
cout << "Search By -" << endl;
int l = submenu();
cout << l;
;
if (l == 1)
{
clrscr();
cout << "\n\nEnter Name: ";
gets(na);
}
if (l == 2)
{
clrscr();
cout << "\n\nEnter Phone No: ";
cin >> pn;
}
if (l == 3)
{
clrscr();
cout << "\n\nEnter Address: ";
gets(add);
}
if (l == 4)
{
clrscr();
cout << "\n\nEnter Internet Address: ";
gets(eid);
}
int n;
n = count();
for (int i = 0; i < n; i++)
{
f3.read((char*)&obj, sizeof(obj));
if (l == 2)
{
if (pn == ph1)
{
view1();
}
}
if (l == 1)
{
if (!strcmp(na, name))
{
view1();
}
}
if (l == 3)
{
if (!strcmp(address1, add))
{
view1();
}
}
if (l == 4)
{
if (!strcmp(eid, intdd))
{
view1();
}
}
}
if (!f3.eof())
{
cout << " \n\n\nRecord Not Found!!!! (The Entered Field Not In Database)\n\n";
}
cout << " \n\n\n Back To Main Menu(y/n)::: ";
cin >> u;
if ((u == 'y') || (u == 'Y'))
menu();
}
void file::init() // ENTERING THE DETAILS
{

clrscr();
char ch;
cout << "Adding Data......Please Fill The Fields Properly ";
cout << " \n\n\n\n\n\n\n Enter Name : ";
gets(name);
cout << " \n Enter House Phone Number : ";
cin >> ph1;
cout << " \n Enter Office Phone Number : ";
cin >> ph2;
cin.get(ch);
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(id, 25, '\n');
cout << " \n Enter Internet Address : ";
cin.getline(intdd, 25, '\n');
}

void file::view1() // TO DISPLAY ALL THE RECORDS


{
cout << "\n";
cout << " Phone Number1 : " << obj.ph1 << "\n";
cout << " Phone Number2 : " << obj.ph2 << "\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.id << "\n";
cout << " Internet Address: " << obj.intdd << "\n";
cout << "\n\nPress Enter For Next Step: ";
getch();
}
void file::modification() // TO MODIFY ANY DATA IN THE RECORD IF NECESSARY
{
clrscr();
long ph = -1;
char na[50], add[50], eid[50];
strcmp(na, '\0');
strcmp(eid, '\0');
strcmp(add, '\0');
cout << na;
cout << "Modification............This Window Allows You to Modify Your Enteries ";
cout << "\n\n\nComputer will ask you for each entry..\n";
long pn;
int l = submenu(), n;
;
;
ifstream f4("data.abk", ios::binary);
ofstream f5("c:\\new", ios::binary);
if (f4.fail())
{
cout << "\n File Not Found !!! ";
getch();
f5.close();
exit(0);
}
n = count();
if (n == 0)
{
cout << "\n File Is Empty !!!!...........No Enteries Found ";
getch();
return;
}
while (f4.good())
{
f4.read((char*)&obj, sizeof(obj));
f5.write((char*)&obj, sizeof(obj));
}
f4.close();
f5.close();
f5.open("data.abk", ios::trunc);
f4.open("new");
if (f4.fail())
{
cout << "\n File Not Found !!!!...........No Enteries Found";
exit(0);
}
char ch;
clrscr();
if (l == 2)
{
cout << "\n\n\n Enter Phone Number :";
cin >> pn;
}
if (l == 1)
{
cout << "\n\n\n Enter Name :";
gets(na);
}
if (l == 3)
{
cout << "\n\n\n Enter Address :";
gets(add);
}
if (l == 4)
{
cout << "\n\n\n Enter InterNet Address :";
gets(eid);
}
int d, z;
for (i = 0; i < n; i++)
{
f4.read((char*)&obj, sizeof(obj));

{
if ((pn == ph1) || (!strcmp(add, address1)) || (!strcmp(eid, intdd))
|| (!strcmp(na, name)))
{
view1();
d = check("House Phone Number ");
if ((d == 1))
{
cout << "\n Enter New Phone Number :";
cin >> ph1;
}
if (check("Office Phone Number ") == 1)
{
cout << "\n Enter New Phone Number :";
cin >> ph2;
}
z = check("Name");
if (z == 1)
{
cout << "\n Enter New Name : ";
gets(name);
}
if (check("Home Address") == 1)
{
cout << "\n Enter New Address :";
gets(address1);
}
if (check("Office Address") == 1)
{
cout << "\n Enter New Address :";
gets(address2);
}
if (check("Email Address:") == 1)
{
cout << "\n Enter New Mail Address :";
gets(id);
}
if (check("Internet Address") == 1)
{
cout << "\n Enter New Internet Address :";
gets(intdd);
}
}
else
x++;

f5.write((char*)&obj, sizeof(obj));
}
}
if (x == n)
{
cout << "\n\n\n***No Other Entry Found***";
}

f5.close();
f4.close();
cout << " \n\n\n Back To Main Menu(y/n)::: ";
cin >> u;
if ((u == 'y') || (u == 'Y'))
menu();
}

void modipass() // MODIFY PASSWORD


{
clrscr();
cout << "\n\nModify Your Master password.......";
char p1[100], p2[100], s;
int a = 0, n = 0;
l:
cout << "\n\n\nEnter New Pasword: ";
gets(p1);
cout << "\nConfirm password: ";
gets(p2);
if (!strcmp(p1, p2))
{
ofstream f1("data1", ios::binary);
cout << "\n\nEncrypting Password.......\n\n\nModification Confirmed.... \n";
a = strlen(p1);

for (i = 0; i < a; i++)


{
n = p1[i];
n = n - 25;
p1[i] = n;
n = 0;
}
f1.write((char*)&p1, sizeof(p1));
f1.close();
cout << "\n\n\nBack to Main Menu(y/n): ";
cin >> s;
if ((s == 'y') || (s == 'Y'))
{
obj.menu();
}
}
else
{
cout << "\nEntered Password Don't Match";
goto l;
}
}

int file::check(char* s) // CHECKS CHOICE


{
cout << "\n Modify...... " << s << "\t"
<< "Y/N";
char ch;
cin >> ch;
if ((ch == 'y') || (ch == 'Y'))
return 1;
else
return 2;
}
void sort() // DATA SORTING
{
file d1, d2[100], t;
clrscr();
char y;
int l, nu, i = 0, j = 0;
ifstream f2("data.abk", ios::binary);
cout << "\nSort File in accending order according to: ";
cout << "\n\n\MENU->\n\n";
cout << " \n1.By Name";
cout << " \n2.By Phone Number";
cout << " \n3.By Address";
cout << " \n4.By Internet ID";
cout << " \n5.Back To main Menu";
cout << "\n\n\nEnter Choice: ";
cin >> y;
l = 0;
switch (y)
{
case '1':
l = 1;
break;
case '2':
l = 2;
break;
case '3':
l = 3;
break;
case '4':
l = 4;
break;
default:
l = 0;
obj.menu();
}

while (f2.read((char*)&d1, sizeof(d1)))


{
d2[i] = d1;
i++;
}
i = i - 1;
f2.close();
nu = i;
for (i = 0; i <= nu - 1; i++)
{
for (j = 0; j <= nu - 1 - i; j++)
{
if (l == 1)
{
if (strcmpi(d2[j].rna(), d2[j + 1].rna()) > 0)
{
t = d2[j];
d2[j] = d2[j + 1];
d2[j + 1] = t;
}
}
if (l == 2)
{
if ((d2[j].rph()) > (d2[j + 1].rph()))
{
t = d2[j];
d2[j] = d2[j + 1];
d2[j + 1] = t;
}
}
if (l == 3)
{
if (!strcmpi(d2[j].radd(), d2[j + 1].radd()) > 0)
{
t = d2[j];
d2[j] = d2[j + 1];
d2[j + 1] = t;
}
}
if (l == 4)
{
if (!strcmpi(d2[j].reid(), d2[j + 1].reid()) >= 0)
{
t = d2[j];
d2[j] = d2[j + 1];
d2[j + 1] = t;
}
}
}
}
cout << "\nData Sorted......writing back...";
ofstream f3("data.abk", ios::binary);
for (i = 0; i <= nu; i++)
f3.write((char*)&d2[i], sizeof(d2[i]));
f3.close();
cout << " \n\n\n Back To Main Menu(y/n)::: ";
cin >> y;
if ((y == 'y') || (y == 'Y'))
obj.menu();
getch();
}

void file::deleate() // MENU FOR DELETION


{
clrscr();
cout << "\n\n\n Deletion............Delete Your Entiries";
int l = submenu();
int f = 0, e;
long pn;
int n, i;
ifstream f1;
ofstream f2;
f1.open("data.abk");
if (f1.fail())
{
cout << "\n\n\n\n File Not Found !!!!";
getch();
return;
}
f2.open("new");
n = count();
if (n == 0)
{
cout << "\n\n\n\n File Is Empty !!!!.............No Enteries Found ";
getch();
return;
}
for (i = 0; i < n; i++)
{
f1.read((char*)&obj, sizeof(obj));
f2.write((char*)&obj, sizeof(obj));
}
f1.close();
f2.close();
f2.open("data.abk", ios::trunc);
f1.open("new");
if (f1.fail())
{
cout << "\n\n\n File Not Found !!!!";
getch();
return;
}
if (l == 2)
{
cout << "\n\n\n\n\n Enter Phone Number :";
cin >> pn;
for (i = 0; i < n; i++)
{
f1.read((char*)&obj, sizeof(obj));
if (pn != ph1)
{
f2.write((char*)&obj, sizeof(obj));
cout << ".";
}
}
}
char na[100];
if (l == 1)
{
cout << "\n\n\n\n\n Enter Name :";
gets(na);
for (i = 0; i < n; i++)
{
f1.read((char*)&obj, sizeof(obj));
if (strcmp(na, name))
{
f2.write((char*)&obj, sizeof(obj));
cout << ".";
}
}
}
if (l == 3)
{
cout << "\n\n\n\n\n Enter Address :";
gets(na);
for (i = 0; i < n; i++)
{
f1.read((char*)&obj, sizeof(obj));
if (strcmp(na, address1))
{
f2.write((char*)&obj, sizeof(obj));
cout << ".";
}
}
}
if (l == 4)
{
cout << "\n\n\n\n\n Enter Internet ID :";
gets(na);
for (i = 0; i < n; i++)
{
f1.read((char*)&obj, sizeof(obj));
if (strcmp(na, intdd))
{
f2.write((char*)&obj, sizeof(obj));
cout << ".";
}
}
}
cout << "Deleting........please wait...";
for (e = 0; e <= 25000; e++)
;
cout << "\n**Deleted**";
f2.close();
f1.close();
cout << " \n\n\n Back To Delete Menu(y/n)::: ";
cin >> u;
if ((u == 'y') || (u == 'Y'))
deleate();
}

void file::view() // VIEW FIELDS


{
ifstream f1;
int n, j;
f1.open("data.abk");
if (f1.fail() || f1.bad())
{
cout << "\n File Not Found!!!!...........No Enteries Found ! ";
getch();
return;
}
clrscr();
int i = 0;
n = count();
for (j = 0; j < n; j++)
{
cout << "\n\n\n\n\n Record " << i + 1 << "->\n";
f1.read((char*)&obj, sizeof(obj));
cout << "\n\n\n Phone Number1 :" << obj.ph1 << "\n";
cout << "\n Phone Number2 :" << obj.ph2 << "\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 Internet Address :" << obj.intdd << "\n";
cout << "\n Email Address : " << obj.id << "\n";
i += 1;
cout << "\n\nPress Enter For Next Step: ";
getch();
}
f1.close();
cout << " \n\n\n Back To Main Menu(y/n)::: ";
cin >> u;
if ((u == 'y') || (u == 'Y'))
menu();
getch();
}
void file::menu() // MAIN MENU
{
char ch;
clrscr();
cout << "\n\n\tPlease Select An Option...........(1, 2, 3, 4, 5, 6, 7, e)";
cout << "\n\tPlease Note That you can return to this window later......\n\n\n\n";
cout << "1: Enter Fields ---- Add Enteries" << endl << endl;
cout << "2: Delete Fields ---- Delete Enteries" << endl << endl;
cout << "3: Modify Fields ---- Modify Previous Data" << endl << endl;
cout << "4: View Fields ---- View Entered Data" << endl << endl;
cout << "5: Search Feilds ---- Search Field By Phone Number" << endl << endl;
cout << "6. Modify Password ---- Modify Your Master Pasword" << endl << endl;
cout << "7. Sort Data FIle ---- Sorts File and Builds Text Version" << endl << endl;
cout << "e. Exit To Windows "
<< "\n\n\n Enter Choice: ";
cin >> ch;
switch (ch)
{
case '1':
addition();
break;
case '2':
deleate();
break;
case '3':
modification();
break;
case '4':
view();
break;
case '5':
search();
break;
case '6':
modipass();
case '7':
sort();
default:
exit(1);
}
}

int main()
{
intro();
pass();
return 0;
}
SNAPSHOTS
Intro:

Main Menu:
Password:

Add Entry:
View Entry:

Modify Menu:
SearchMenu:

SortMenu:
Modify Password:
BIBLOGRAPHY

The Project concentrates on the concepts and functions given in our


textbook, producing this software.
I thank my computer teacher Mrs sonica for her sincere efforts in
clearing my concepts.

The ideas and Functions in this project have been taken up from various
soft-wares available, and looks into providing all these functions to the
user.

You might also like