Write the following program in C++
Write the following program in C++
Create a class called Employee that includes attributes: empid, name, points,
group, and avg with data types: “int”, “String”, “double”, “String”, and “double” respectively.
2. Include a constructor with parameters: empid and name.
3. Include another constructor to assign default values to the attributes.
4. Include a function called addPoints that is used to add a given amount to the value
of the attribute points.
5. Include a function called upgradePoints that is used to increase the value of the attribute points by a given percentage.
6. Include a function called removePoints that is used to reduce a given amount from the value of the attribute points. If the resultant value is negative then the value of the attribute should be set into zero.
7. Include a function called computeGroup that assigns a value to the attribute group based on the value of the attribute points as given in the following table.
Points | Group |
points < 100 | Silver |
100 ≤ points < 500 | Gold |
500 < points ≤ 2000 | Platinum |
2000 < points | Diamond |
8. Include a function called display to display the values of all the attributes of a Employee object.
9. Include a static function called getBest that returns the value of the attribute id of the Employee with maximum number of points.
10. Create an array in main function that holds five Employee objects. Assign the objects given in the following table to each array element using the parameterized
constructor.
Attributes | obj[0] | obj[1] | obj[2] | obj[3] | obj[4] |
Id | 1543 | 6561 | 6954 | 3485 | 8546 |
Name | Adil | Waseem | Ayesha | Adnan | Wajid |
11. Use the function addPoints to add following points respectively to each Employee object created above. 129, 785, 3258, 59, 1652
12. Add extra 1000 points to the third employee using the function addPoints.
13. Increase the points of the second employee by 2% using the function
upgradePoints.
14. call the function display
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images