COMP2243 - Programming and Problem Solving

Syllabus Software Installation Assignments Tests
Lectures and Labs
**Back to Full Menu**

OOP - Encapsulation Right Triangle OOP Program
RightTriangleClass.java
RightTriangleClient.java

Loan OOP Program
Loan.java
LoanCompany.java

Payroll OOP Program
PayrollClass.java
PayrollDepartment.java

Delivery OOP Program
PackageClass.java
DeliveryCompany.java

Fraction OOP Program
Fraction.java
FractionClient.java




Loan OOP Program


Description

This is an OOP program that uses Loan objects to calculate the monthly payment of the loans.

The formula to calculate the monthly payment is as follows.



The ADT (abstract data type) is Loan.java.

The client program is LoanCompany.java.

Associated Concepts:

Object Oriented Programming (OOP)

Data member: instance variable

Instance method

Constructor

Getter and getter

toString method

Algorithm:

For Loan class, the class diagram is represented in UML (Unified Modeling Language) notation.



Client program:

Create the mortgage loan object using the overloaded constructor with the user input data

Use the object reference to call the method to calculate the monthly payment

Print the object's information

Create the car loan object using the overloaded constructor with the hard-coded data

Compare two objects to determine which has the higher monthly payment

Compare two objects to determine which has the higher interest rate

Source Code