Question: QUESTION 2 Given the following super class and subclasses: public abstract class Staff protected String id; protected String name; protected double income; protected int yearService;

 QUESTION 2 Given the following super class and subclasses: public abstractclass Staff protected String id; protected String name; protected double income; protected

QUESTION 2 Given the following super class and subclasses: public abstract class Staff protected String id; protected String name; protected double income; protected int yearService; //Methods: //constructors, accessor, toString() public abstract double netIncome (); } public class Permanent extends Staff private char grade; //A, B or C private double kwsp; //74 of income //Methods : //constructors, accessor, toString() public double net Income () (....) } public class contract extends Staff | private boolean is Professional; //true or false //Methods: //constructors, accessor, toString() public double netIncome () } a) Write the following method definition: i) Normal constructor for both subclasses. (6 marks) ii) Processor method named net Income () for both subclasses that calculate and return the net income based on following information: The net income for a permanent staff is calculated based on grade (percent Paid) by using the following formula: net Income = (income + (yearService * percentPaid * income)) - kwsp (78 of income) Grade A B percentPaid (%) 8 12 15 The net income for a Contract staff is given based on professional service or not; if the staff is in professional service, the net income is using the following formula: net Income = income + (20% of income) + 150.00 for every year of service Otherwise; the following formula is used to calculate the net income: net Income = income + 120.00 for every year of service (9 marks) b) Write fragment codes in application that perform the following tasks: i) Declare an array of object named stf where the size is entered by the user. (2 marks) ii) Calculate and display the total net income of every category of staff (every subclass) (5 marks) iii) Determine the highest income for professional Contract staff and display information about the staff using toString() method. (8 marks)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!