Employee Raise
Home ] Up ] Employee Class ] [ Employee Raise ] Manager Class ] Everybody Raise ]

 

 

Now, imagine that you want to give all Employees a raise:

package company;

import java.util.Date;

public class EmployeeTest
{
    public static void main(String[] args)
    {
        Employee[] staff = new Employee[3];

        staff[0] = new Employee("Charlie Chaplin",
                                34000,
                                new Date(78, 7, 9));
        staff[1] = new Employee("Florence Nightingale",
                                100,
                                new Date(71, 4, 23));
        staff[2] = new Employee("Mother Theresa",
                                0,
                                new Date(89, 3, 5));
        for (int i = 0; i < staff.length; i++)
            staff[i].raiseSalary(5);     // by 5 percent
        for (int i = 0; i < staff.length; i++)
            staff[i].print();
    }
}

This produces the following output:

Charlie Chaplin 35700.0 1978
Florence Nightingale 105.0 1971
Mother Theresa 0.0 1989

 

This page was last modified on 02 October, 2007