Answer to Question #174485 in C++ for Keega

Question #174485

The class employee comprises of employee details such as emp_id(integer type), employee name(character array type) ,basic salary(float type), allowance(float type) and PF(float type). Get three employee details using getemployee() method and use display() method to calculate and display the net salary(basic salary+allowance+PF) of employees.

Note:Use the concept of class and objects.



1
Expert's answer
2021-03-24T12:46:27-0400
#include <iostream>

using namespace std;

class employee
{
  int   emp_id;
  char  emp_name[20];
  float emp_basic_salary;
  float emp_da;
  float emp_PF;
  float emp_net_sal;

  public:

    void get_emp_details();
    float find_net_salary(float basic_salary, float da, float PF);
    void display_emp_details();
};

void employee :: get_emp_details()
{
  cout<<"\nEnter employee id: ";
  cin>>emp_id;
  cout<<"\nEnter employee name: ";
  cin>>emp_name;
  cout<<"\nEnter employee basic_salary: ";
  cin>>emp_basic_salary;
  cout<<"\nEnter employee DA: ";
  cin>>emp_da;
  cout<<"\nEnter employee PF: ";
  cin>>emp_PF;
}

float employee :: find_net_salary(float basic_salary, float da, float PF)
{
    return (basic_salary+da)-PF;
}

void employee :: display_emp_details()
{
  cout<<"\n\n**** Details of  Employee ****";
  cout<<"\nEmployee Name      :  "<<emp_name;
  cout<<"\nEmployee number    :  "<<emp_id;
  cout<<"\nBasic salary       :  "<<emp_basic_salary;
  cout<<"\nEmployee DA        :  "<<emp_da;
  cout<<"\nIncome Tax         :  "<<emp_PF;
  cout<<"\nNet Salary         :  "<<find_net_salary(emp_basic_salary, emp_da, emp_PF);
  cout<<"\n-------------------------------\n\n";
}


int main()
{
    employee emp;
   
    emp.get_emp_details();
    emp.display_emp_details();

    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS