Introduction. In this assignment you are required to develop a GUI application named Mortgage Calculator. It works in the same way as mortgage calculators provided by various banks, and calculates fortnightly repayments and balances at the end of each year, until the mortgage is fully repaid. The approximate way in which the application should appear is given below. See image.

In the following picture a sample output is shown: See image.

Here we entered the following values:

  • loan amount – 100000 AUD
  • loan term – 10 years
  • interest – 5.8%

After pressing the Calculate button, the fortnightly repayments and balances at the end of each year are calculated and displayed. For example, the balance after 5 years is 57199.05 AUD.

Code for the methods that calculate “daily repayments” and “the balance after a given number of days” is provided.

class Mortgage.

You are required to develop class Mortgage satisfying the following requirements:

  • The class has three instance variables:
    • private double interest – the annual interest on the mortgage;
    • private double loanAmount – the amount borrowed;
    • private int loanTerm – the number of years the mortgage is given for.
  • You should provide constructor(s) for the class, and get and set methods for each of the instance variables.
  • The class also has two methods:
    • public double getDailyRepayments() – calculates daily repayments required to completely repay the mortgage in time.
    • public double balanceAfterDays(int d) – returns the balance (amount of money still owed) after d days.

Code for both methods is given below:

public double getDailyRepayments(){
double a = interest/365;
double days = loanTerm*365;
return a*loanAmount/(1-1/Math.pow(1+a,days));

public double balanceAfterDays(int d){
double a = interest/365;
double days = loanTerm*365;
return loanAmount*(Math.pow(1+a,days)-Math.pow(1+a,d))/(Math.pow(1+a,days)-1);

class MortgageCalculator.

The class extends JFrame class. Its content pane contains the following GUI components

  • nine labels, feel free to add more labels if required.
  • four textFields – to receive values for the loan amount, loan term, interest, and to display fortnightly repayments. The last textField must be uneditable.
  • A textArea (scrollable) – it displays results of the calculations in the way shown on the second picture above.
  • A button named Calculate. Pressing it launches the event handler that makes all required calculations, and displays the results in the textArea. If any of the textFields contain information in the wrong format (not numerical as required), the event handler throws a NumberFormatException object and shows the following message (JOptionPane): See image.

Warning. In this task you are not allowed to use designer (drag and drop) tools provided by Eclipse or other IDEs. The whole program must be written manually. Failing to do so will result in no marks for the whole assignment.

Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.