Tuesday, 9 December 2014

3. Develop an object oriented program in C++ to create a database of the personnel information system containing the following information: Name, Date of Birth, Blood group, Height, Weight, Insurance Policy, number, Contact address, telephone number, driving license no. etc Construct the database with suitable member functions for initializing and destroying the data viz. constructor, default constructor, copy, constructor, destructor, static member functions, friend class, this pointer, inline code and dynamic memory allocation operators-new and delete.


/* Problem Statement:

Develop an object oriented program in C++ to create a database of the personnel information system containing the following information: Name, Date of Birth, Blood group, Height, Weight, Insurance Policy, number, Contact address, telephone number, driving license no. etc Construct the database with suitable member functions for initializing and destroying the data viz. constructor, default constructor, copy, constructor, destructor, static member functions, friend class, this pointer, inline code and dynamic memory allocation operators-new and delete.

*/

#include<iostream>
#include<string>
#include<cstring>
using namespace std;
class person
{
    private:
    char name[40],dob[15],bdg[15];
    int h,w;
    public:
    static int count;
    friend class personal;
    person()
    {
        char * name=new char[40];
        char *dob=new char[80];
        char *bdg=new char[15];
        h=w=0;
    }
    static void recordcount()
    {
        cout<<"\n Total no of records :"<<count;
    }
};

class personal
{
private:
  char add[70],telephone[15],policy_no[10];
public:
 personal()
{
    strcpy(add,"");
    strcpy(telephone,"");
    strcpy(policy_no,"");
}
void getdata(person *obj);
void displaydata(person *obj);
friend class person;
};
int person::count=0;
void personal::getdata(person *obj)
{
cout<<"\n Enter Name of Person=";
cin>>obj->name;
cout<<"\n Enter date of birth of person=";
cin>>obj->dob;
cout<<"\n Enter blood group of person=";
cin>>obj->bdg;
cout<<"\n Enter height and weigth of person=";
cin>>obj->h>>obj->w;
cout<<"\n Enter Contact no of person=";
cin>>this->telephone;
cout<<"\n Enter addreass of person=";
cin>>this->add;
cout<<"\n Enter the insurance policy no=";
cin>>this->policy_no;
obj->count++;
}
void personal::displaydata(person *obj)
{

cout<<obj->name<<"\t"<<obj->dob<<"\t\t"<<obj->bdg<<"\t"<<obj->h<<"\t\t"<<obj->w<<"\t"<<this->telephone<<"\t"<<this->policy_no<<"\t"<<this->add;
}
int main()
{
personal *p1[30];
person *p2[30];
int n=0,ch,i;
do
{
cout<<"\n Menu";
cout<<"\n 1.Information of Person \n 2.Display Information \n 3.Exit";
cout<<"\n Enter your choice";
cin>>ch;
switch(ch)
{
case 1:
 cout<<"\n Enter The Information";
 cout<<"\n";
 p1[n]=new personal;
 p2[n]=new person;
p1[n]->getdata(p2[n]);
n++;
person::recordcount();
break;
case 2:
 cout<<"\n";
cout<<"\n*******************************************************************\n";
cout<<"NAME"<<"\t"<<"DATE OF BIRTH"<<"\t"<<"BLOOD GROUP"<<"\t"<<"HEIGHT"<<"\t"<<"WEIGHT"<<"\t"<<"TELEPHONE NO"<<"\t"<<"INSU.POLICYNO"<<"\t"<<"ADDRESS \n";
cout<<"\n";
for(i=0;i<n;i++)
{
p1[i]->displaydata(p2[i]);

}
person::recordcount();
break;
}
}while(ch!=4);
return 0;
}

1 comment:

  1. hey bro what i enter in blood group
    there is no proceed after blood group

    ReplyDelete