Define a class Employee with the following specifications: PRIVATE DATA MEMBERS: Empno integer type Empname 25 characters BasicPay float type HRA float type DA float type TA float type PF integer type NetSalary float type PUBLIC MEMBERS FUNCTIONS: Employee() Default constructor to initialize data member BasicPay = HRA = DA = TA = PF = NetSalary = 0 Employee(ENo, Ename) Parameterized constructor to accept values for Empno and Empname Employee(BP, HRA, DA, TA, PF) Parameterized constructor to accept values for BasicPay, HRA, DA, TA and PF Calculate() Function to calculate the NetSalary, NetSalary=(NET=BASIC HRA DA TA)-PF Display() Function to display all the information about the employee ~Employee() Destructor to destroy the data objects
Answers
Answer:
the answer is in the attachment hope it helps
Answer:
class named "Employee" in C++ that implements the specifications you provided:
class Employee
{
private:
int Empno;
char Empname[25];
float BasicPay, HRA, DA, TA, NetSalary;
int PF;
public:
Employee()
{
BasicPay = HRA = DA = TA = PF = NetSalary = 0;
}
Employee(int ENo, char Ename[])
{
Empno = ENo;
strcpy(Empname, Ename);
}
Employee(float BP, float hra, float da, float ta, int pf)
{
BasicPay = BP;
HRA = hra;
DA = da;
TA = ta;
PF = pf;
}
void Calculate()
{
NetSalary = (BasicPay + HRA + DA + TA) - PF;
}
void Display()
{
cout << "Employee Number: " << Empno << endl;
cout << "Employee Name: " << Empname << endl;
cout << "Basic Pay: " << BasicPay << endl;
cout << "HRA: " << HRA << endl;
cout << "DA: " << DA << endl;
cout << "TA: " << TA << endl;
cout << "PF: " << PF << endl;
cout << "Net Salary: " << NetSalary << endl;
}
~Employee()
Explanation:
This code defines a class named "Employee" in C++ that has several private data members and public member functions.
The private data members of the class include:
Empno: an integer type that represents the employee number.
Empname: a character array of 25 elements that represents the employee name.
BasicPay, HRA, DA, TA, and NetSalary: float types that represent the basic pay, HRA, DA, TA and net salary of the employee.
PF: an integer type that represents the employee's provident fund.
The public member functions of the class include:
Employee(): This is the default constructor of the class. It is used to initialize all the data members of the class to zero.
Employee(int ENo, char Ename[]): This is a parameterized constructor that accepts values for Empno and Empname.
Employee(float BP, float hra, float da, float ta, int pf): This is a parameterized constructor that accepts values for BasicPay, HRA, DA, TA and PF.
Calculate(): This is a function that calculates the net salary of the employee. It uses the formula NetSalary = (BasicPay + HRA + DA + TA) - PF.
Display(): This function displays all the information about the employee including Empno, Empname, BasicPay, HRA, DA, TA, PF and NetSalary.
~Employee(): This is a destructor of the class which deallocate the memory and destroy the data objects created by the class.
The class can be used to create objects of type Employee and to perform various operations on these objects such as calculating the net salary, displaying the information of an employee and freeing the memory used by the class.
More questions and answers
https://brainly.in/question/50192228
https://brainly.in/question/53687108
#SPJ3