Solution to Design a class to represent a Employee details. Include the following members. Data Members • … - Sikademy
Author Image

Archangel Macsika

Design a class to represent a Employee details. Include the following members. Data Members • Employee Name • Employee ID • Department Name •Basic Salary. Methods • To assign initial values • compute Net salary * print employee details. To Incorporate a constructor to provide initial values and array of objects.

The Answer to the Question
is below this banner.

Can't find a solution anywhere?

NEED A FAST ANSWER TO ANY QUESTION OR ASSIGNMENT?

Get the Answers Now!

You will get a detailed answer to your question or assignment in the shortest time possible.

Here's the Solution to this Question

#include <iostream> #include <string> using namespace std; class Employee { string EmpName; int EmpId; string DepName; float BasicSalary; public: //Default constructor Employee(){} //Parametrized constructor Employee(string _EmpName, int _EmpId, string _DepName, float _BasicSalary) :EmpName(_EmpName), EmpId(_EmpId), DepName(_DepName), BasicSalary(_BasicSalary){} void Assign() { cout << "Please, enter Employee Name: "; cin>> EmpName; cout << "Please, enter Employee ID: "; cin >> EmpId; cout << "Please, enter Department Name: "; cin >> DepName; cout << "Please, enter Basic Salary: "; cin >> BasicSalary; } float ComputeNetSalary() { float taxes, allows; cout << "Please, enter taxes (from 0 to 40): "; cin >> taxes; cout << "Please, enter allowances (from 0 to 100): "; cin >> allows; taxes = taxes / 100; allows =allows / 100; return (BasicSalary + BasicSalary*allows - BasicSalary*taxes); } void Print() { cout << "\nEmployee Name: " << EmpName << "\nEmployee ID: " << EmpId << "\nDepartment Name: " << DepName << "\nBasicSalary: " << BasicSalary << endl; } }; int main() { //Parametrized constructor Employee a("Jack", 1234, "Workers", 2000); cout<<"\nNet salary is "<<a.ComputeNetSalary(); a.Print(); Employee b; b.Assign(); cout << "\nNet salary is " << b.ComputeNetSalary(); b.Print(); Employee arr[5]; for (int i = 0; i < 5; i++) { arr[i].Assign(); } for (int i = 0; i < 5; i++) { arr[i].Print(); } }

Related Answers

Was this answer helpful?

Join our Community to stay in the know

Get updates for similar and other helpful Answers

Question ID: mtid-3-stid-44-sqid-1011-qpid-8