Write a C++ program that maintains a collection of employees. Private data that is associated with an Employee class: Em

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Write a C++ program that maintains a collection of employees. Private data that is associated with an Employee class: Em

Post by answerhappygod »

Write a C++ program that maintains a collection of
employees.
Private data that is associated with an Employee
class:
Emp_ID
Age (between 25-50)
Salary_per_month
Total_deductions
Annual_salary_with_deductions
Public functions that can be performed on Employee
object:
Default Constructor: (constructor without arguments). This
should set 0 initially for the data members Emp_ID, Age,
Salary_per_month, Total_deductions and
Annual_salary_with_deductions for the object created without
passing any values.
Constructor: (constructor with arguments). This should set the
values for the data members Emp_ID, Age and Salary_per_month as per
user’s choice for the object created by using three values. But,
the Total_deductions and Annual_salary_with_deductions data members
alone should be set to 0 initially in this three parametrized
constructor. While setting value to the member data “Age”
validation should be performed to check whether the given age is
between 25 and 50 only. If so, user input can be set as value to
“Age”. Otherwise, print “Invalid” and exit the program.
Annual_Salary: This function should compute annual salary of the
employee based on the “this” pointer after the following deductions
from the annual salary.
Deduction details:-
Income tax: 10% from the annual salary.
Educational chess: 5% from the annual salary.
Professional tax: 3% from the annual salary.
Then set Total_deductions (sum of income tax, educational
chess and professional tax) and Annual_salary_with_deductions
(Salary_per_month * 12 – Total_deductions) of the employee by using
“this” pointer and print the annual salary with the complete
deduction details of the employees.
Compare_emp: This function should compare two employees’ annual
salaries after all deductions and find which employee is paid high.
This function should carry two objects as arguments and after
comparison, it should return an object from the function to the
main function which is having the highly paid employee details.
Print_emp: This function should displays all data members of the
object passed as the argument to it.
Note:-
Write a main function that tests Employee class as
follows:
Create two objects of type Employee using argument
constructor to initialize it member data as per user’s choice to
Emp_ID, Age and Salary_per_month. But Total_deductions and
Annual_salary should be set to 0 initially.
Compute the annual salary for these employee objects and print
the same with complete deduction details.
Compare both the employees to find the highly paid employee.
Display the details of the highly paid employee.
You may decide the type of the member data as per the
requirements.
Output is case sensitive. Therefore, it should be produced as
per the sample test case representations.
Age should be between 25 and 50 only. Otherwise, print
“Invalid”.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply