Question: Answer accordingly. Do not give full coding. Given the following superclass named Staff and subclasses named Normal and Admin: Superclass: Staff Attributes : String staffId



Given the following superclass named Staff and subclasses named Normal and Admin: Superclass: Staff Attributes : String staffId String name double basicSalary boolean professional //true or false Methods : normal constructor mutator accessors toString() abstract double calculate Salary() Subclass : Normal Attributes : double basicAllowance Methods : normal constructor mutator accessors toString() abstract method definition Subclass : Admin Attributes : double adminAllowance int adminLevel //1, 2, 3 Methods : normal constructor mutator accessors toString() abstract method definition a. Write the definition of method calculateSalary() for both subclasses that calculate and return the total salary using the following information: For normal staff, the total salary will be calculated as shown in Table 1. Type Table 1 Total Salary basic salary + basic allowance + 500 basic salary + basic allowance + 100 Profesional Non-profesional For admin staff, the total salary will be calculated as shown in Table 2. Type Profesional Non-profesional Table 2 Total Salary basic salary + admin allowance + 800 basic salary + admin allowance + 500 (8 marks) b. Write program fragments for the following questions using the polymorphism concept. i. Declare an array of 450 staffs' objects named stf. (1 mark) ii. Calculate and display the total salary for each professional type. (3 marks) iii. Display the staff name and his/her total salary for every level 1 administration staff
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
