THINK FIRST·CODE LATER

← All labs

Employee and Manager: inheritance

Problem

Write a class Employee with private name and salary (double), a constructor, getName(), getSalary(), a method raise(double percent) that increases the salary, and toString() returning name earns 2000.00.

Write Manager extending Employee with an extra field department. Its constructor calls super(...), and it overrides toString() to return name earns 3000.00 (department).

Payroll reads: name, salary, then manager name, manager salary, department. It raises both by 10% and prints the two objects, the manager first.

Write it here or in your IDE, then paste it. Compile and test it yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.