steverobinson

Student and Staff

Oct 12th, 2010
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.11 KB | None | 0 0
  1. /*      Student & Staff Details        */
  2. /*            Language: C++            */
  3.  
  4.  
  5.  
  6. #include <iostream.h>
  7. #include <conio.h>
  8.  
  9. class base
  10. {
  11.     protected:
  12.         char name[30];
  13.         char address[150];
  14.     public:
  15.         base(){}
  16.  };
  17.  
  18. class student:private base
  19. {
  20.     private:
  21.         float marks;
  22.  
  23.     public:
  24.         student(){}
  25.  
  26.         void get_details()
  27.         {
  28.             fflush(stdin);
  29.             cout<<"\nEnter the Name of the Student: ";
  30.             cin.getline(name,30);
  31.             cout<<"\nEnter the Address: ";
  32.             cin.getline(address,150);
  33.             cout<<"\nEnter the Percentage of Marks Scored: ";
  34.             cin>>marks;
  35.         }
  36.         void display_details()
  37.         {
  38.             cout<<"\nName: "<<name;
  39.             cout<<"\nAddress: "<<address;
  40.             cout<<"\n Percentage: "<<marks<<"%";
  41.         }
  42. };
  43.  
  44. class staff:private base
  45. {
  46.     private:
  47.         float salary;
  48.  
  49.     public:
  50.         staff(){}
  51.  
  52.         void get_details()
  53.         {
  54.             fflush(stdin);
  55.             cout<<"\nEnter the Name of the Staff: ";
  56.             cin.getline(name,30);
  57.             cout<<"\nEnter the Address: ";
  58.             cin.getline(address,150);
  59.  
  60.             cout<<"\nEnter the Salary: ";
  61.             cin>>salary;
  62.         }
  63.         void display_details()
  64.         {
  65.             cout<<"\nName: "<<name;
  66.             cout<<"\nAddress: "<<address;
  67.             cout<<"\n Salary: "<<"Rs."<<salary;
  68.         }
  69. };
  70.  
  71. int main()
  72. {
  73.     system("cls");
  74.     student student1;
  75.     staff staff1;
  76.     cout<<"\n\nEnter Details for the Student: \n";
  77.     student1.get_details();
  78.     cout<<"\n\nEnter Details for the Staff: \n";
  79.     staff1.get_details();
  80.  
  81.     cout<<"\n----------------------------------------------------------\n\n";
  82.     cout<<"\nDetails of the Student are: ";
  83.     student1.display_details();
  84.     cout<<"\n----------------------------------------------------------\n\n";
  85.  
  86.     cout<<"\nDetails of the Staff are: ";
  87.     staff1.display_details();
  88.     cout<<"\n----------------------------------------------------------\n\n";
  89.  
  90.     getch();
  91.     return 0;
  92. }
Add Comment
Please, Sign In to add comment