Answer to Question #178404 in C++ for Varshini

Question #178404

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-04-06T15:57:17-0400
#include<iostream>

using namespace std;
class Employee {
private:    
  int   emp_id;
  char  emp_name[32];
  float basic_salary;
  float allowance;
  float PF;
 
public :
    void getemployee();
 //   float find_net_salary(float basic_salary, float da, float PF);
    void display();
};

void Employee :: getemployee()
{
  cout << endl << "Enter employee id: ";
  cin  >> emp_id;
  cout << "Enter employee name: ";
  cin.ignore();
  cin.getline(emp_name, 32);
  cout << "Basic_salary: ";
  cin  >> basic_salary;
  cout << "Allowance: ";
  cin  >> allowance;
  cout << "PF: ";
  cin  >>PF;
}

void Employee::display() {
    cout <<"===============================" << endl
         <<"Employee ID   "<< emp_id << endl
         <<"Employee name " << emp_name <<endl
         <<"Basic salary " << basic_salary << endl
         <<"Allowance    " << allowance << endl
         <<"PF           "<< PF << endl
         <<"Net salary   "<<basic_salary+allowance+PF << endl<<endl;
}
int main()
{
    Employee Emp01;
    Emp01.getemployee();
    Emp01.display();
    
    Employee Emp02;
    Emp02.getemployee();
    Emp02.display();
    
    Employee Emp03;
    Emp03.getemployee();
    Emp03.display();        

    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