Write a program for employees database
Write a program for employees database
PROGRAM:
#include<iostream> #include<stdio.h> #include<stdlib.h> using namespace std; class staff{ int code; char name[10]; public: void set_details(){ cout<<"Enter code : "; cin>>code; cout<<"Enter Name : "; cin>>name; } void get_details(){ cout<<"\ncode : "<<code<<"\t"<<"name : "<<name; } }; class edu:public staff{ char educat[10]; public: void set_edu(){ cout<<"\nEnter qualification :"<<endl; cin>>educat; } void get_edu(){ cout<<"\nqualification : "<<educat; } }; class officer:public edu{ char grade[2]; public: void set_grade(){ cout<<"Enter grade : "; cin>>grade; } void get_grade(){ cout<<"\ngrade : "<<grade; } }; class typist:public staff{ float speed; public: void set_speed(){ cout<<"Enter speed of typist : "; cin>>speed; } void get_speed(){ cout<<"\nspeed :"<<speed; } }; class regular:public typist{ int payment; public: void set_pay(){ cout<<"Enter payment of typist : "; cin>>payment; } void get_pay(){ cout<<"\npayment :"<<payment; } }; class casual:public typist{ int daily_wags; public: void set_wags(){ cout<<"Enter daily_wags of typist : "; cin>>daily_wags; } void get_wags(){ cout<<"\nwags : "<<daily_wags; } }; class teacher:public edu{ char sub[10],pub[10]; public: void set_teadata(){ cout<<"Enter subject and publication teacher teaching : "; cin>>sub>>pub; } void get_teadata(){ cout<<"\nsub : "<<sub<<"\t"<<"pub : "<<pub; } }; int main(){ officer o[10]; teacher t[10]; casual c[10]; regular r[10]; int choice; int i=0,j=0,k=0,l=0; char ch; do{ cout<<"\n1.officer database \n2.teacher database\n3.casual typist database\n4.regular typist database \n5.Database\nEnter choice : "; cin>>choice; switch(choice){ case 1: o[i].set_details(); o[i].set_grade(); o[i].set_edu(); i++; break; case 2: t[j].set_details(); t[j].set_teadata(); t[j].set_edu(); j++; break; case 3: c[k].set_details(); c[k].set_speed(); c[k].set_wags(); k++; break; case 4: r[l].set_details(); r[l].set_speed(); r[l].set_pay(); l++; break; case 5: if(i>0){ cout<<"\n Officer details\n"<<endl; for(int a=i-1;a>=0;a--){ o[a].get_details(); o[a].get_grade(); o[a].get_edu(); }} if(j>0){ cout<<"\n teacher details\n"<<endl; for(int a=j-1;a>=0;a--){ t[a].get_details(); t[a].get_teadata(); t[a].get_edu(); }} if(k>0){ cout<<"\n casual typist details\n"<<endl; for(int a=k-1;a>=0;a--){ c[a].get_details(); c[a].get_speed(); c[a].get_wags(); }} if(l>0){ cout<<"\n regular typist details\n"<<endl; for(int a=l-1;a>=0;a--){ r[a].get_details(); r[a].get_speed(); r[a].get_pay(); }} //i++;j++;k++;l++; break; default: cout<<"\n Wrong choice\n"; break; } cout<<"\n Enter 'y' to continue : "; cin>>ch; system("CLS"); }while(ch=='y'); return 0; }
Comments
Post a Comment