Java Reference
In-Depth Information
58
System.out.printf(
59
"new base salary with 10%% increase is: $%,.2f%n" ,
60
employee.getBaseSalary());
61
} // end if
62
63
System.out.printf(
64
"earned $%,.2f%n%n" ,
currentEmployee.earnings()
);
65
} // end for
66
67
// get type name of each object in employees array
for ( int j = 0 ; j < employees.length; j++)
System.out.printf( "Employee %d is a %s%n" , j,
employees[j].getClass().getName());
68
69
70
71
} // end main
72
} // end class PayrollSystemTest
Employees processed individually:
salaried employee: John Smith
social security number: 111-11-1111
weekly salary: $800.00
earned: $800.00
hourly employee: Karen Price
social security number: 222-22-2222
hourly wage: $16.75; hours worked: 40.00
earned: $670.00
commission employee: Sue Jones
social security number: 333-33-3333
gross sales: $10,000.00; commission rate: 0.06
earned: $600.00
base-salaried commission employee: Bob Lewis
social security number: 444-44-4444
gross sales: $5,000.00; commission rate: 0.04; base salary: $300.00
earned: $500.00
Employees processed polymorphically:
salaried employee: John Smith
social security number: 111-11-1111
weekly salary: $800.00
earned $800.00
hourly employee: Karen Price
social security number: 222-22-2222
hourly wage: $16.75; hours worked: 40.00
earned $670.00
commission employee: Sue Jones
social security number: 333-33-3333
gross sales: $10,000.00; commission rate: 0.06
earned $600.00
Fig. 10.9 | Employee hierarchy test program. (Part 3 of 4.)
Search WWH ::




Custom Search