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

Padovan string, a padovan string p(n) for a natural number n is defined a...

a padovan string p(n) for a natural number n is defined as p(0)=''x'' p(1)=''y'' p(2)=''z'' p(n)=p(n-2)+p(n-3),n>2

Sums a sequence of integers, assume that the first integer read with cin sp...

assume that the first integer read with cin specifies the number of values remaining to be entered. that program should read only one value each time cin is executed .a typical inp

Luminous Jewels - The Polishing Game, Byteland county is very famous for lu...

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

#padovan string in c , #padovan string in java   program in java /...

#padovan string in java   program in java // aakash , suraj , prem sasi kumar kamaraj college program 1 : package test.padovanstring; public class PadovanStrin

Give a formal expression of the specification, A function REPAT is specifie...

A function REPAT is specified below. Function REPAT(c in Char, i in Int, s in mString) return in mString pre 1 ≤ i ≤ the length of s. post The returned value is a string identic

Define the data type modifiers in c language, Define the Data Type Modifier...

Define the Data Type Modifiers in C language? There are three data types(int, float & double) above have the following modifiers. 1. short 2. long 3. signed 4. unsigned

Explain topologies for the network information system, Problem: a) Give...

Problem: a) Give and Illustrate with the help of diagrams, four topologies for the Network Information System (NIS). b) Give methods for creating user accounts and groups.

Problem : Compiler Design - Limit the methods, Rahul is a newbie to the pro...

Rahul is a newbie to the programming and while learning the programming language he came to know the following rules: · Each program must start with ''{'' and end with '

Minimum shelves, write a c++ program, that finds the minimum total number o...

write a c++ program, that finds the minimum total number of shelves, including the initial one, required for this loading process.

What is a union how does it differ from a structure, Question : (a) (i)...

Question : (a) (i) What is a structure member in C? What is the relationship between a structure member and the structure? (ii) How can structure variables be declared in C?

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