Write a program for employees database

Write a program for employees database

PROGRAM:
  1. #include<iostream>
  2. #include<stdio.h>
  3. #include<stdlib.h>
  4. using namespace std;
  5. class staff{
  6. int code;
  7. char name[10];
  8. public:
  9. void set_details(){
  10. cout<<"Enter code : ";
  11. cin>>code;
  12. cout<<"Enter Name : ";
  13. cin>>name;
  14. }
  15. void get_details(){
  16. cout<<"\ncode : "<<code<<"\t"<<"name : "<<name;
  17. }
  18. };
  19. class edu:public staff{
  20. char educat[10];
  21. public:
  22. void set_edu(){
  23. cout<<"\nEnter qualification :"<<endl;
  24. cin>>educat;
  25. }
  26. void get_edu(){
  27. cout<<"\nqualification : "<<educat;
  28. }
  29. };
  30.  
  31. class officer:public edu{
  32. char grade[2];
  33. public:
  34. void set_grade(){
  35. cout<<"Enter grade : ";
  36. cin>>grade;
  37. }
  38. void get_grade(){
  39. cout<<"\ngrade : "<<grade;
  40. }
  41. };
  42. class typist:public staff{
  43. float speed;
  44. public:
  45. void set_speed(){
  46. cout<<"Enter speed of typist : ";
  47. cin>>speed;
  48. }
  49. void get_speed(){
  50. cout<<"\nspeed :"<<speed;
  51. }
  52. };
  53. class regular:public typist{
  54. int payment;
  55. public:
  56. void set_pay(){
  57. cout<<"Enter payment of typist : ";
  58. cin>>payment;
  59. }
  60. void get_pay(){
  61. cout<<"\npayment :"<<payment;
  62. }
  63. };
  64. class casual:public typist{
  65. int daily_wags;
  66. public:
  67. void set_wags(){
  68. cout<<"Enter daily_wags of typist : ";
  69. cin>>daily_wags;
  70. }
  71. void get_wags(){
  72. cout<<"\nwags : "<<daily_wags;
  73. }
  74. };
  75. class teacher:public edu{
  76. char sub[10],pub[10];
  77. public:
  78. void set_teadata(){
  79. cout<<"Enter subject and publication teacher teaching : ";
  80. cin>>sub>>pub;
  81. }
  82. void get_teadata(){
  83. cout<<"\nsub : "<<sub<<"\t"<<"pub : "<<pub;
  84. }
  85. };
  86. int main(){
  87. officer o[10];
  88. teacher t[10];
  89. casual c[10];
  90. regular r[10];
  91. int choice;
  92. int i=0,j=0,k=0,l=0;
  93. char ch;
  94. do{
  95. cout<<"\n1.officer database \n2.teacher database\n3.casual typist database\n4.regular typist database \n5.Database\nEnter choice : ";
  96. cin>>choice;
  97. switch(choice){
  98. case 1:
  99. o[i].set_details();
  100. o[i].set_grade();
  101. o[i].set_edu();
  102. i++;
  103. break;
  104.  
  105. case 2:
  106. t[j].set_details();
  107. t[j].set_teadata();
  108. t[j].set_edu();
  109. j++;
  110. break;
  111.  
  112. case 3:
  113. c[k].set_details();
  114. c[k].set_speed();
  115. c[k].set_wags();
  116. k++;
  117. break;
  118.  
  119. case 4:
  120. r[l].set_details();
  121. r[l].set_speed();
  122. r[l].set_pay();
  123. l++;
  124. break;
  125. case 5:
  126. if(i>0){
  127. cout<<"\n Officer details\n"<<endl;
  128. for(int a=i-1;a>=0;a--){
  129. o[a].get_details();
  130. o[a].get_grade();
  131. o[a].get_edu();
  132. }}
  133. if(j>0){
  134. cout<<"\n teacher details\n"<<endl;
  135. for(int a=j-1;a>=0;a--){
  136. t[a].get_details();
  137. t[a].get_teadata();
  138. t[a].get_edu();
  139. }}
  140. if(k>0){
  141. cout<<"\n casual typist details\n"<<endl;
  142. for(int a=k-1;a>=0;a--){
  143. c[a].get_details();
  144. c[a].get_speed();
  145. c[a].get_wags();
  146. }}
  147. if(l>0){
  148. cout<<"\n regular typist details\n"<<endl;
  149. for(int a=l-1;a>=0;a--){
  150. r[a].get_details();
  151. r[a].get_speed();
  152. r[a].get_pay();
  153. }}
  154. //i++;j++;k++;l++;
  155. break;
  156.  
  157.  
  158. default:
  159. cout<<"\n Wrong choice\n";
  160. break;
  161. }
  162. cout<<"\n Enter 'y' to continue : ";
  163. cin>>ch;
  164. system("CLS");
  165. }while(ch=='y');
  166.  
  167. return 0;
  168. }
  169.  
  170.  

Comments

Popular posts from this blog

Introduction to ChatGPT: Explain what ChatGPT is, how it works, and what it is used for.

Multi Level Inheritance In cpp

Hybrid Inheritance In cpp