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”.
In samples test cases in order to understand the inputs and
outputs better the comments are given inside a particular notation
(…….). When you are inputting get only appropriate values to the
corresponding attributes and ignore the comments (…….) section. In
the similar way, while printing output please print the appropriate
values of the corresponding attributes and ignore the comments
(…….) section.
Sample Test cases:-
case=one
input=123 (Emp_ID)
21 (Age)
50000 (Salary)
124 (Emp_ID)
23 (Age)
60000 (Salary)
output=Employee 1
Income tax=5000
Educational chess=2500
Professional tax=1500
Total deductions=9000
Annual salary without deductions=600000
Annual salary with deductions=591000
Employee 2
Income tax=6000
Educational chess=3000
Professional tax=1800
Total deductions=10800
Annual salary without deductions=720000
Annual salary with deductions=709200
Highly paid is Employee 2
Emp_ID=124
Age=23
Salary per month=60000
Total deductions=10800
Annual salary with deductions=709200
grade reduction=15%
case=two
input=123 (Emp_ID)
21 (Age)
50000 (Salary)
124 (Emp_ID)
53 (Age)
60000 (Salary)
output=Invalid
grade reduction=15%
case=three
input=123 (Emp_ID)
51 (Age)
50000 (Salary)
124 (Emp_ID)
23 (Age)
60000 (Salary)
output= Invalid
grade reduction=15%
case=four
input=100 (Emp_ID)
21 (Age)
80000 (Salary)
124 (Emp_ID)
23 (Age)
70000 (Salary)
output= Employee 1
Income tax=8000
Educational chess=4000
Professional tax=2400
Total deductions=14400
Annual salary without deductions=960000
Annual salary with deductions=945600
Employee 2
Income tax=7000
Educational chess=3500
Professional tax=2100
Total deductions=12600
Annual salary without deductions=840000
Annual salary with deductions=827400
Highly paid is Employee 1
Emp_ID=100
Age=21
Salary per month=80000
Total deductions=14400
Annual salary with deductions=945600
grade reduction=15%
Write a C++ program that maintains a collection of employees. Private data that is associated with an Employee class: Em
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am