C program to maintain database of employees, C/C++ Programming

Assignment Help:

Aim: To implement a program to maintain information of employees in an educational institute using inheritance.

Code:                      

class staff

{

            int code;

            char name[20];

            public:

            void getdata();

            void displaydata();

};

class teacher:staff

{

            char subject[10];

            char publication[20];

            public:

            void getdata();

            void displaydata();

};

 

class typist:staff

{

            int speed;

            public:

            void getdata();

            void displaydata();

};

 

class regular:typist

{

            int salary;

            public:

            void getdata();

            void displaydata();

};

 

class casual:typist

{

            int daily_wages;

            public:

            void getdata();

            void displaydata();

};

 

class officer:staff

{

            int grade;

            public:

            void getdata();

            void displaydata();

};

void staff::getdata()

{

            cout<<"\nEmployee code: ";

            cin>>code;

            cout<<"Name: ";

            cin>>name;

}

void officer::getdata()

{

            staff::getdata();

            cout<<"Enter Officer Grade: ";

            cin>>grade;

}

void teacher::getdata()

{

            staff::getdata();

            cout<<"Enter Subject: ";

            cin>>subject;

            cout<<"Enter Publication: ";

            cin>>publication;

}

void typist::getdata()

{

            staff::getdata();

            cout<<"Enter typing speed: ";

            cin>>speed;

}

void regular::getdata()

{

            typist::getdata();

            cout<<"Enter salary: ";

            cin>>salary;

}

void casual::getdata()

{

            typist::getdata();

            cout<<"Enter daily Wages: ";

            cin>>daily_wages;

}

void staff::displaydata()

{

            cout<<"\nEmployee code: "<

            cout<<"\nName: "<

}

void officer::displaydata()

{

            staff::displaydata();

            cout<<"\nOfficer Grade: "<

}

void teacher::displaydata()

{

            staff::displaydata();

            cout<<"\nSubject: "<

            cout<<"\nPublication: "<

}

void typist::displaydata()

{

            staff::displaydata();

            cout<<"\nTyping speed: "<

}

void regular::displaydata()

{

            typist::displaydata();

            cout<<"\nSalary: Rs."<

}

void casual::displaydata()

{

            typist::displaydata();

            cout<<"Daily Wages: Rs."<

}

void main()

{

            int ch;

            clrscr();

            do

            {

                        cout<<"\n\n1. Teacher\n2. Officer\n3. Typist\n4. Exit\nEnter your choice:";

                        cin>>ch;

                        switch(ch)

                        {

                                    case 1:

                                    teacher t1;

                                    cout<<"\n\tEnter Teacher's Details:";

                                    t1.getdata();

                                    cout<<"\n\t**Details Registered Successfully**\n\n";

                                    t1.displaydata();

                                    break;

 

                                    case 2:

                                    officer o1;

                                    cout<<"\n\tEnter Officer's Details:";

                                    o1.getdata();

                                    cout<<"\n**\tDetails Registered Successfully**\n\n";

                                    o1.displaydata();

                                    break;

 

                                    case 3:

                                    int typ;

                                    cout<<"\n1. Regular Typist\n2. Casual Typist\nEnter choice:";

                                    cin>>typ;

                                    switch (typ)

                                    {

                                                case 1:

                                                regular tr1;

                                                cout<<"\n\tEnter Typist's Details:";

                                                tr1.getdata();

                                                cout<<"\n**\tDetails Registered Successfully**\n\n";

                                                tr1.displaydata();

                                                break;

 

                                                case 2:

                                                casual tc1;

                                                cout<<"\n\tEnter Typist's Details:";

                                                tc1.getdata();

                                                cout<<"\n**\tDetails Registered Successfully**\n\n";

                                                tc1.displaydata();

                                                break;

 

                                                default:

                                                cout<<"Wrong Selection!";

                                    }

                        }

            }while(ch!=4);

getch();

}

Output:

1. Teacher

2. Officer

3. Typist

4. Exit

Enter your choice: 3

 

1. Regular Typist

2. Casual Typist

Enter choice:2

 

        Enter Typist's Details:

Employee code: 555

Name: Anjali

Enter typing speed: 53

Enter daily Wages: 250

 

**      Details Registered Successfully**

Employee code: 555

Name: Anjali

Typing speed: 53 wpm

Daily Wages: Rs.250

 

1. Teacher

2. Officer

3. Typist

4. Exit

Enter your choice:4


Related Discussions:- C program to maintain database of employees

Define procedure to input integers and returns the average, The procedure +...

The procedure +, * and list take arbitrary numbers of arguments. One way to define such a procedure is to use define with dotted-tail notation. In a procedure definition, a paramet

Write a program to change the matrix program, Change the matrix program (pr...

Change the matrix program (program 3) slightly. Overload == operator to compare two matrices to be added or subtracted. i.e., whether the column of first and the row of second

Genetic disease, Many human diseases could be controlled by the knowledge o...

Many human diseases could be controlled by the knowledge of the gene’s structure and pattern. The human gene could be represented by four nucleotides. Each nucleotide is represente

Pattern, enter height of the shape: 1 3 5 3 1 3 5 7 5 3 5 7 9 7 5 3 5 7...

enter height of the shape: 1 3 5 3 1 3 5 7 5 3 5 7 9 7 5 3 5 7 5 3 1 3 5 3 1

Program to print a series, Write a program called Series that will print/di...

Write a program called Series that will print/display a series of numbers starting with 1 and ending with the last number that is less than 30. The series should include only odd n

Explain the continue statement, The continue statement The continue sta...

The continue statement The continue statement causes the next iteration of the enclosing loop to start. When this is encountered in the loop , the rest of the statements in the

Illustrate the example of constructor, A Constructive Example Consider ...

A Constructive Example Consider an example , to model a user-defined data type for  strings. The object simulates a character array ( string ) using a character pointer and an

Program to create local shopping cart, Available, and the right kind of pro...

Available, and the right kind of programs. My son wants to stop using ice. He has organised detox a number of times, and is always successful. It is the next stage, rehab, where

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd