Advertisement
albela

Untitled

Apr 18th, 2021
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.37 KB | None | 0 0
  1. // Q1.Write a program to display employee information using class and member function.
  2. //solution:-
  3. #include<iostream>
  4. #include<conio.h>
  5.  
  6. using namespace std;
  7.  
  8. class employee
  9. {
  10.     int   emp_number;
  11.     char  emp_name[20];
  12.     float emp_basic;
  13.     float emp_da;
  14.     float emp_it;
  15.     float emp_net_sal;
  16.  
  17.     public:
  18.  
  19.         void get_emp_details();
  20.         float find_net_salary(float basic, float da, float it);
  21.         void show_emp_details();
  22. };
  23.  
  24. void employee :: get_emp_details()
  25. {
  26.     cout<<"\nEnter employee number: ";
  27.     cin>>emp_number;
  28.     cout<<"\nEnter employee name: ";
  29.     cin>>emp_name;
  30.     cout<<"\nEnter employee basic: ";
  31.     cin>>emp_basic;
  32.     cout<<"\nEnter employee DA: ";
  33.     cin>>emp_da;
  34.     cout<<"\nEnter employee IT: ";
  35.     cin>>emp_it;
  36. }
  37.  
  38. float employee :: find_net_salary(float basic, float da, float it)
  39. {
  40.     return (basic+da)-it;
  41. }
  42.  
  43. void employee :: show_emp_details()
  44. {
  45.     cout<<"\n\n**** Details of  Employee ****";
  46.     cout<<"\nEmployee Name      :  "<<emp_name;
  47.     cout<<"\nEmployee number    :  "<<emp_number;
  48.     cout<<"\nBasic salary       :  "<<emp_basic;
  49.     cout<<"\nEmployee DA        :  "<<emp_da;
  50.     cout<<"\nIncome Tax         :  "<<emp_it;
  51.     cout<<"\nNet Salary         :  "<<find_net_salary(emp_basic, emp_da, emp_it);
  52.     cout<<"\n-------------------------------\n\n";
  53. }
  54.  
  55.  
  56. int main()
  57. {
  58.     employee emp;
  59.    
  60.     emp.get_emp_details();
  61.     emp.show_emp_details();
  62.  
  63.     return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement