You are required to write a Java program that computes salaries for a variety of employees, using object-oriented programming and inheritance principles.
The program should include four classes:
-
Employee (Base class)
-
Holds employee’s name and monthly salary.
-
Methods:
-
Constructor to initialize data
-
annualSalary()
method to return yearly salary -
toString()
method to describe the employee
-
-
-
Salesman (Subclass of Employee)
-
Adds annual sales.
-
Methods:
-
Constructor
-
Overridden
annualSalary()
(includes commission: 2% of sales, up to $20,000) -
Overridden
toString()
-
-
-
Executive (Subclass of Employee)
-
Adds stock price.
-
Methods:
-
Constructor
-
Overridden
annualSalary()
(includes $30,000 bonus if stock > $50) -
Overridden
toString()
-
-
-
Payroll (Main class)
-
Reads employee info from a file (for years 2014 and 2015, max 10 employees each).
-
Stores employees in arrays by year.
-
Prints a report for each year, showing employee info and annual salary, and computes the average salary for the year.