Develop an object oriented program in C++ to create a database of student information system containing the following information: Name, Roll number, Class, division, Date of Birth, Blood group, 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.

 Develop an object oriented program in C++ to create a database of student information

system containing the following information: Name, Roll number, Class, division, Date of

Birth, Blood group, 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.

OUTPUT FOR THE PROGRAM


#include<iostream>

#include<iomanip>

#include<cstring>

using namespace std;


class personal

{

char bg[5],name[20],dob[10];

char Class[5],div[5];

float height,weight;

int ins_pno,roll;

char cadd[20];

char ph_no[20];

int dlno;

static int cnt;

public:

friend class derived;

personal()

{

strcpy(name,"Deepika");

roll=24;

strcpy(Class,"SE");

strcpy(div,"A");

strcpy(dob,"3Jul1980");

strcpy(bg,"O+ve");

height=6.0;

weight=58;

ins_pno=1722;

strcpy(cadd,"Mumbai");

strcpy(ph_no,"90021874846");

dlno=6810;

}

personal(char name[],int roll,char Class[],char div[],char dob[],char bg[],float height,float weight,int ins_pno,char cadd[],char ph_no[],int dlno)

{

strcpy(this->name,name);

this->roll=roll;

strcpy(this->Class,Class);

strcpy(this->div,div);

strcpy(this->dob,dob);

strcpy(this->bg,bg);

this->height=height;

this->weight=weight;

this->ins_pno=ins_pno;

strcpy(this->cadd,cadd);

strcpy(this->ph_no,ph_no);

this->dlno=dlno;

}

personal(personal &p)

{

strcpy(p.name,name);

p.roll=roll;

strcpy(p.Class,Class);

strcpy(p.div,div);

strcpy(p.dob,dob);

strcpy(p.bg,bg);

p.height=height;

p.weight=weight;

p.ins_pno=ins_pno;

strcpy(p.cadd,cadd);

strcpy(p.ph_no,ph_no);

p.dlno=dlno;

}

static void showcount()

{

cnt++;

cout<<"\nCount is : "<<cnt;

}

~personal()

{

cout<<"\n Object is Destroyed "<<endl;

}

};

class  derived

{

public:

void accept(personal &p)

{

      cout<<"Enter the Name : ";

      cin>>p.name;

      cout<<"Enter the Roll Number : ";

      cin>>p.roll;

              cout<<"Enter the Class : ";

      cin>>p.Class;

              cout<<"Enter the Division : ";

      cin>>p.div;

      cout<<"Enter the Date of Birth:";

      cin>>p.dob;

      cout<<"Enter the Blood Group:";

      cin>>p.bg;

      cout<<"Enter the Height:";

      cin>>p.height;

      cout<<"Enter the Weight:";

      cin>>p.weight;

      cout<<"Enter the Insurance Policy no:";

      cin>>p.ins_pno;

      cout<<"Enter the Contact Address:";

      cin>>p.cadd;

      cout<<"Enter the phone no:";

      cin>>p.ph_no;

      cout<<"Enter the driving lisence no:";

      cin>>p.dlno;

}

inline void display(personal &p)

{

      cout<<endl<<endl;

      cout<<setw(12)<<p.name;

              cout<<setw(8)<<p.roll;

      cout<<setw(8)<<p.Class;

              cout<<setw(8)<<p.div;

      cout<<setw(12)<<p.dob;

      cout<<setw(7)<<p.bg;

      cout<<setw(8)<<p.height;

      cout<<setw(9)<<p.weight;

      cout<<setw(8)<<p.ins_pno;

      cout<<setw(14)<<p.cadd;

      cout<<setw(15)<<p.ph_no;

      cout<<setw(8)<<p.dlno;

}

};

int personal::cnt;


int main()

{


    personal *d1;

    derived d;

    int i,n;

    cout<<"\n Constructor Values\n\n";

    cout<<setw(12)<<"NAME";

cout<<setw(10)<<"ROLL_NO";

cout<<setw(8)<<"CLASS";

cout<<setw(8)<<"DIV";

    cout<<setw(10)<<"DOB";

    cout<<setw(7)<<"BG";

    cout<<setw(10)<<"HEIGHT";

    cout<<setw(10)<<"WEIGHT";

    cout<<setw(8)<<"InsPN";

    cout<<setw(12)<<"CADDRESS";

    cout<<setw(14)<<"PH_NO";

    cout<<setw(9)<<"DLN";


    personal p("Ranveer",19,"SE","A","1Oct1970","O+ve",6.2,60,123,"Delhi","90899977644",456);

    d.display(p);

    personal::showcount();


    personal p1;

    d.display(p1);

    personal::showcount();


    cout<<"\nEnter How many records you want to insert:";

    cin>>n;

    d1=new personal[n];

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

    {

d.accept(d1[i]);

    }

    cout<<endl;

    cout<<setw(12)<<"NAME";

cout<<setw(10)<<"ROLL_NO";

cout<<setw(8)<<"CLASS";

cout<<setw(8)<<"DIV";

    cout<<setw(10)<<"DOB";

    cout<<setw(7)<<"BG";

    cout<<setw(10)<<"HEIGHT";

    cout<<setw(10)<<"WEIGHT";

    cout<<setw(8)<<"InsPN";

    cout<<setw(12)<<"CADDRESS";

    cout<<setw(14)<<"PH_NO";

    cout<<setw(9)<<"DLN";

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

    {

d.display(d1[i]);

    personal::showcount();

    }

    return 0;

}


                                                                              ********* OUTPUT **********


/*

Constructor Values


        NAME   ROLL_NO   CLASS     DIV       DOB     BG    HEIGHT    WEIGHT   InsPN CADDRESS         PH_NO      DLN


       Mayur      19      SE       A   15Oct2000   O+ve     6.2       60     123     Nandurbar     9089177644     456

Count is : 1


       Ketan      24      SE       A   30Jul2000   O+ve       6       58    1722        Satana     9021874846    6810

Count is : 2

Enter How many records you want to insert:2

Enter the Name : Akshay

Enter the Roll Number : 10

Enter the Class : SE

Enter the Division : A

Enter the Date of Birth:08/3/2000

Enter the Blood Group:B+ve

Enter the Height:5.5

Enter the Weight:50

Enter the Insurance Policy no:487

Enter the Contact Address:Mumbai

Enter the phone no:98456122454

Enter the driving lisence no:449

Enter the Name : Amir

Enter the Roll Number : 03

Enter the Class : SE

Enter the Division : A

Enter the Date of Birth:09/10/2000

Enter the Blood Group:O+ve

Enter the Height:5.3

Enter the Weight:50

Enter the Insurance Policy no:786

Enter the Contact Address:Delhi

Enter the phone no:8975684235

Enter the driving lisence no:422


        NAME   ROLL_NO   CLASS     DIV       DOB     BG    HEIGHT    WEIGHT   InsPN    CADDRESS         PH_NO      DLN


    Akshay      10      SE       A   08/3/2000   B+ve     5.5       50     487        Mumbai     98456122454     449

Count is : 3


       Amir       3               A  09/10/2000   O+ve     5.3       50     786        Delhi     8975684235     422

Count is : 4

 Object is Destroyed 


 Object is Destroyed 


*/


For more such posts click the link:-http://svencrai.com/G8W


Comments

Popular posts from this blog

A book shop maintains the inventory of books that are being sold at the shop. The list includes details such as author, title, price, publisher and stock position. Whenever a customer wants a book, the sales person inputs the title and author and the system searches the list and displays whether it is available or not. If it is not, an appropriate message is displayed. If it is, then the system displays the book details and requests for the number of copies required. If the requested copies book details and requests for the number of copies required. If the requested copies are available, the total cost of the requested copies is displayed; otherwise the message ?Required copies not in stock? is displayed. Design a system using a class called books with suitable member functions and Constructors. Use new operator in constructors to allocate memory space required. Implement C++ program for the system

Write C++ program for storing appointment schedule for day. Appointments are booked randomly using linked list. Set start and end time and min and max duration for visit slot. Write functions for- a)Display free slots b)Book appointment c)Cancel appointment ( check validity, time bounds, availability etc) d)Sort list based on time e)Sort list based on time using pointer manipulation

Imagine a publishing company which does marketing for book and audiocassette versions. Create a class publication that stores the title (a string) and price (type float) of a publication. From this class derive two classes: book, which adds a page count (type int), and tape, which adds a playing time in minutes (type float). Write a program that instantiates the book and tape classes, allows user to enter data and displays the data members.