Loading...
Loading...
Loading...
Every employee gets 10% of the salary as a festival bonus. A manager gets the employee bonus plus Rs. 5000, and an intern gets a flat Rs. 1000. Write Employee with long bonus(), and Manager and Intern that override it; Manager must reuse the parent rule with super.bonus().
EMP, MGR or INTERN), a one-word name and a monthly salary.<name> <bonus> for each person, in input order.Example
Input
3 EMP Rohan 42000 MGR Priya 90000 INTERN Arjun 15000
Output
Rohan 4200 Priya 14000 Arjun 1000
Priya: 9000 + 5000 = 14000.
Try the problem first. Open one hint at a time.
Keep name and salary in Employee, set by a constructor; the children pass them up with super(name, salary).
Manager.bonus() is return super.bonus() + 5000;.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor