Contact Management System: Project

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

PROJECT

CONTACT MANAGEMENT
SYSTEM
CODE:
#include<iostream>
#include<string>

using namespace std;

//structure for input


struct Telephone
{
string First_name;
string Last_name;
string Phone_number;
};
//array of structure
Telephone Array[1000];
string F_name;
string L_name;
string P_number;
int S_number;

//Add operation
int Add(int& size)
{
int choice;
char ch;
do
{

cout << "How many data do you want to enter\n";


cin >> choice;
for (int i = size; i < (size + choice); i++)
{

cout << "Enter your full name\n";


cin >> Array[i].First_name;
cin >> Array[i].Last_name;
cout << "Enter phone number\n";
cin >> Array[i].Phone_number;

}
size = size + choice;
cout << "Do you want more inputs press Y/N : \n";
cin >> ch;
} while (ch == 'y');
return 0;
}
//Display data
int show(int& size)
{
//heading
cout << "|-------------------------------------------------------------------|\n";
cout << "|Sn.|\t|NAme\t\t\t\t|Phone Number|\t\t |\n";
cout << "|-------------------------------------------------------------------|\n";
//Display of entred data
for (int i = 0; i < size; i++)
{
cout << "|" << i + 1 << ")|";
cout << "\t";
cout << Array[i].First_name << " ";
cout << Array[i].Last_name;
cout << "|\t\t\t|";
for (int j = i; j <= i; j++)
{
cout << Array[j].Phone_number;
}cout << endl;
}return 0;
}
//Searching data in directory
int Search(int& size)
{
int choice;
do
{

cout << "1)Search by Name\n";


cout << "2)Search by Phone number\n";
cout << "3)Search by Serial number\n";
cout << "Enter your choice for Operation:\n";
cin >> choice;
switch (choice)
{
case 1:
cout << "Enter full name which you want to Search...!\n";
cin >> F_name;
cin >> L_name;
for (int i = 0; i < size; i++)
{
/*cout <<
"|-------------------------------------------------------------------|\n";
cout << "|Sn.|\t|NAme\t\t\t\t|Phone Number|\t\t |\n";
cout <<
"|-------------------------------------------------------------------|\n";*/
if (Array[i].First_name == F_name && Array[i].Last_name ==
L_name)
{
cout << "|" << i + 1 << ")|";
cout << "\t";
cout << Array[i].First_name << " ";
cout << Array[i].Last_name;
cout << "|\t\t\t|";
for (int j = i; j <= i; j++)
{
cout << Array[j].Phone_number;
}cout << endl;
}
}
break;
case 2:
cout << "Enter full number which you want to Search...!\n";
cin >> P_number;
for (int i = 0; i < size; i++)
{
cout <<
"|-------------------------------------------------------------------|\n";
cout << "|Sn.|\t|NAme\t\t\t\t|Phone Number|\t\t |\n";
cout <<
"|-------------------------------------------------------------------|\n";
if (Array[i].Phone_number == P_number)
{
cout << "|" << i + 1 << ")|";
cout << "\t";
cout << Array[i].First_name << " ";
cout << Array[i].Last_name;
cout << "|\t\t\t|";
for (int j = i; j <= i; j++)
{
cout << Array[j].Phone_number;
}cout << endl;
}
}
break;
case 3:
cout << "Enter Serial number in which you want to change\n";
cin >> S_number;
for (int i = 0; i < size; i++)
{
cout <<
"|-------------------------------------------------------------------|\n";
cout << "|Sn.|\t|NAme\t\t\t\t|Phone Number|\t\t |\n";
cout <<
"|-------------------------------------------------------------------|\n";
if (i == S_number)
{
cout << "|" << i + 1 << ")|";
cout << "\t";
cout << Array[i].First_name << " ";
cout << Array[i].Last_name;
cout << "|\t\t\t|";
for (int j = i; j <= i; j++)
{
cout << Array[j].Phone_number;
}cout << endl;
}
}
break;
default:
cout << "Input invalid\n\tThank you\n";
}
cout << "For more changes press 1\n";
cin >> choice;
} while (choice == 1);
return 0;
}
//modify data in directory
int Modify(int& size)
{
int choice;
do
{
cout << "1)Change by Name\n";
cout << "2)Change by Phone number\n";
cout << "3)Change by Serial number\n";
cout << "Enter your choice for Operation:\n";
cin >> choice;
switch (choice)
{
case 1:
cout << "Enter full name which you want to change\n";
cin >> F_name;
cin >> L_name;
for (int i = 0; i < size; i++)
{
if (Array[i].First_name == F_name && Array[i].Last_name ==
L_name)
{
cout << "Enter your full name\n";
cin >> Array[i].First_name;
cin >> Array[i].Last_name;
cout << "ENter phone number\n";
cin >> Array[i].Phone_number;
}
}
cout << "Press 1 for mor change\n";
break;
case 2:
cout << "Enter full number in which you want to change\n";
cin >> P_number;
for (int i = 0; i < size; i++)
{
if (Array[i].Phone_number == P_number)
{
cout << "Enter your full name\n";
cin >> Array[i].First_name;
cin >> Array[i].Last_name;
cout << "ENter phone number\n";
cin >> Array[i].Phone_number;
}
}
break;
case 3:
cout << "Enter Serial number in which you want to change\n";
cin >> S_number;
for (int i = 0; i < size; i++)
{
if (i == S_number)
{
cout << "Enter your full name\n";
cin >> Array[i].First_name;
cin >> Array[i].Last_name;
cout << "Enter phone number\n";
cin >> Array[i].Phone_number;
}
}
break;
default:
cout << "Input invalid\n";
}
cout << "For more changes press 1\n";
cin >> choice;
} while (choice == 1);
return 0;
}
//delete data from directory
int Delete(int& size)
{
int choice;
do
{
cout << "1)Delete by Name\n";
cout << "2)Delete by Phone number\n";
cout << "3)Delete by Serial number\n";
cout << "Enter your choice for Operation:\n";
cin >> choice;
switch (choice)
{
case 1:
cout << "Enter full name which you want to Delete\n";
cin >> F_name;
cin >> L_name;
for (int i = 0; i < size; i++)
{
if (Array[i].First_name == F_name && Array[i].Last_name ==
L_name)
{
for (int j = i; j < size; j++)
{
i = i + 1;
}
}

}size--;
cout << "Press 1 for more change\n";
break;
case 2:
cout << "Enter full number in which you want to change\n";
cin >> P_number;
for (int i = 0; i < size; i++)
{
if (Array[i].Phone_number == P_number)
{

for (int j = i; j < size; j++)


{
i = i + 1;
}
}
}size--;
break;
case 3:
cout << "Enter Serial number in which you want to change\n";
cin >> S_number;
for (int i = 0; i < size; i++)
{
if (i == S_number)
{
for (int j = i; j < size; j++)
{
i = i + 1;
}
}
}
size--;
break;
default:
cout << "Input invalid\n";
}
cout << "For more changes press 1\n";
cin >> choice;
} while (choice == 1);
return 0;
}
//Main function
int main()
{

int choice;
int size = 0;

//heading
cout << "\t\t\
t-------------------------------------------------------------------";
cout << "\t\t\t\t\t\t\t\t\tWELCOME TO YOUR CONTACT MANAGEMENT SYSTEM\n"; \
cout << "\t\t\
t-------------------------------------------------------------------\n";

//background colour

do
{
//choices
cout << "1) Add rew record\n";
cout << "2) Display all record\n";
cout << "3) Search contact number \n";
cout << "4) Update data \n";
cout << "5) Delete record \n";
cout << "Entre your choice for operation :\n";
cin >> choice;
switch (choice)
{
case 1:
Add(size);
break;
case 2:
show(size);
break;
case 3:
Search(size);
break;
case 4:
Modify(size);
break;
case 5:
Delete(size);
break;
default:
cout << "Input invalid\n";
}
cout << "Press 0 to go to main program...!\n";
cin >> choice;
system("cls");
} while (choice == 0);
return 0;
}

You might also like