Payroll OOP Program
Description
We studied Payroll program in previous sections.In this section, we write an OOP program that uses the PayrollClass object to calculate the weekly pay.
The ADT (abstract data type) is PayrollClass.java.
The client program is PayrollDepartment.java.
Associated Concepts:
Object Oriented Programming (OOP)
Data member: instance variable
Instance method
Constructor
Getter and getter
toString method
Instance method
Constructor
Getter and getter
toString method
Algorithm:
For PayrollClass, the class diagram is represented in
UML (Unified Modeling Language) notation.
Client program:
Client program:
Create the PayrollClass object p1 using the overloaded constructor
with the user input data
Use the object reference p1 to call the method to calculate the weekly pay
Print the object p1's information
Create the PayrollClass object p2 using the default constructor
Set p2's data members with hard-coded values
Use the object reference p2 to call the method to calculate the weekly pay
Print the object p2's information
Double p1's hourly wage
Compare the weekly pays of two objects
Use the object reference p1 to call the method to calculate the weekly pay
Print the object p1's information
Create the PayrollClass object p2 using the default constructor
Set p2's data members with hard-coded values
Use the object reference p2 to call the method to calculate the weekly pay
Print the object p2's information
Double p1's hourly wage
Compare the weekly pays of two objects
Source Code
PayrollClass.java Source CodePayrollDepartment.java Source Code