#include<iostream.h>
#include<string.h>
#include<conio.h>
class telephone
{
char name[10],city[10];
long phone;
public:
void search(telephone,char*);
void search(telephone,long);
void search(char*,telephone);
void accept();
};

void telephone::accept()
{
cout<<"\n\nEnter customer name : ";
cin>>name;
cout<<"\n\nEnter customer phone number : ";
cin>>phone;
cout<<"\n\nEnter city : ";
cin>>city;
}

void telephone::search(telephone a,char *n)
{
if((strcmp(n,a.name))==0)
{
cout<<"\n\nPhone Number is : "<<a.phone;
}
}

void telephone::search(telephone a,long num)
{
if(num==a.phone)
{
cout<<"\n\nCustomer name is : "<<a.name;
}
}

void telephone::search(char *c,telephone a)
{
if((strcmpi(c,a.city))==0)
{
cout<<"\n\n"<<a.name;
}
}

int main()
{
clrscr();
cout<<"\n\nEnter how many records you want to enter : ";
int k;
cin>>k;
char a1[10],a2[10];
long l;
telephone obj[10];
cout<<"\n\nEnter the details of customer : ";
for(int i=0;i<k;i++)
obj[i].accept();
cout<<"\n\nEnter name of a customer whose phone number you want to search : ";
cin>>a1;
for(i=0;i<k;i++)
obj[i].search(obj[i],a1);
cout<<"\n\nEnter phone number of a customer whose name you want to search : ";
cin>>l;
for(i=0;i<k;i++)
obj[i].search(obj[i],l);
cout<<"\n\nEnter city name : ";
cin>>a2;
cout<<"\n\nFollowing are the customers from "<<a2<<" city";
for(i=0;i<k;i++)
obj[i].search(a2,obj[i]);
getch();
return 0;

}

Post a Comment

Previous Post Next Post