Object-Oriented Programming Assignment: Loan Amortization Calculator
VerifiedAdded on  2025/05/01
|9
|437
|426
AI Summary
Desklib provides past papers and solved assignments for students. This is a solved Java programming assignment.

MITS4002
OBJECT-ORIENTED SOFTWARE
DEVELOPMENT
Activity 09
Student ID:
Student full name:
Total Points (20 pts):
OBJECT-ORIENTED SOFTWARE
DEVELOPMENT
Activity 09
Student ID:
Student full name:
Total Points (20 pts):
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

1. Design
2. Coding
Start.java
import java.text.DecimalFormat;
public class Start extends javax.swing.JFrame {
public Start() {
initComponents();
}
private void initComponents() {
amtloan1 = new javax.swing.JLabel();
yrsLabel = new javax.swing.JLabel();
amount_of_loanTF = new javax.swing.JTextField();
num_of_yrsTF = new javax.swing.JTextField();
2. Coding
Start.java
import java.text.DecimalFormat;
public class Start extends javax.swing.JFrame {
public Start() {
initComponents();
}
private void initComponents() {
amtloan1 = new javax.swing.JLabel();
yrsLabel = new javax.swing.JLabel();
amount_of_loanTF = new javax.swing.JTextField();
num_of_yrsTF = new javax.swing.JTextField();

display_button = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
amtloan1.setFont(new java.awt.Font("Arial", 1, 18));
amtloan1.setText("Amount of Loan");
yrsLabel.setFont(new java.awt.Font("Arial", 1, 18));
yrsLabel.setText("Number of Years");
amount_of_loanTF.addActionListener(new
java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
amount_of_loanTFActionPerformed(evt);
}
});
num_of_yrsTF.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt) {
num_of_yrsTFActionPerformed(evt);
}
});
display_button.setText("Display The Table");
display_button.addActionListener(new
java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jLabel3 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
amtloan1.setFont(new java.awt.Font("Arial", 1, 18));
amtloan1.setText("Amount of Loan");
yrsLabel.setFont(new java.awt.Font("Arial", 1, 18));
yrsLabel.setText("Number of Years");
amount_of_loanTF.addActionListener(new
java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
amount_of_loanTFActionPerformed(evt);
}
});
num_of_yrsTF.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt) {
num_of_yrsTFActionPerformed(evt);
}
});
display_button.setText("Display The Table");
display_button.addActionListener(new
java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

display_buttonActionPerformed(evt);
}
});
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane1.setViewportView(jTextArea1);
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayou
t.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(amtloan1)
.addGap(18, 18, 18)
.addComponent(amount_of_loanTF,
javax.swing.GroupLayout.PREFERRED_SIZE, 115,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentP
lacement.RELATED, 14, Short.MAX_VALUE)
.addComponent(yrsLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentP
lacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(num_of_yrsTF,
javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentP
lacement.RELATED, 98, Short.MAX_VALUE))
}
});
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane1.setViewportView(jTextArea1);
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayou
t.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(amtloan1)
.addGap(18, 18, 18)
.addComponent(amount_of_loanTF,
javax.swing.GroupLayout.PREFERRED_SIZE, 115,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentP
lacement.RELATED, 14, Short.MAX_VALUE)
.addComponent(yrsLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentP
lacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(num_of_yrsTF,
javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentP
lacement.RELATED, 98, Short.MAX_VALUE))
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

.addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE, 630,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel3,
javax.swing.GroupLayout.PREFERRED_SIZE, 89,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGap(281, 281, 281)
.addComponent(display_button)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayou
t.Alignment.BASELINE)
.addComponent(yrsLabel)
.addComponent(amount_of_loanTF,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(num_of_yrsTF,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(amtloan1))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayou
t.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(141, 141, 141)
.addComponent(jLabel3)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SI
ZE, Short.MAX_VALUE))
javax.swing.GroupLayout.PREFERRED_SIZE, 630,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel3,
javax.swing.GroupLayout.PREFERRED_SIZE, 89,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGap(281, 281, 281)
.addComponent(display_button)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayou
t.Alignment.BASELINE)
.addComponent(yrsLabel)
.addComponent(amount_of_loanTF,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(num_of_yrsTF,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(amtloan1))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayou
t.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(141, 141, 141)
.addComponent(jLabel3)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SI
ZE, Short.MAX_VALUE))

.addGroup(layout.createSequentialGroup()
.addGap(23, 23, 23)
.addComponent(display_button)
.addPreferredGap(javax.swing.LayoutStyle.ComponentP
lacement.RELATED)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.DEFAULT_SIZE, 320, Short.MAX_VALUE)
.addContainerGap())))
);
pack();
}
private void amount_of_loanTFActionPerformed(java.awt.event.ActionEvent
evt) {
}
public void showLoan(double amount_loan, double num_of_yrs) {
DecimalFormat df2 = new DecimalFormat("#.00");
jTextArea1.append("Interest rate "+"Monthly Payment
"+"Total Payment \n");
for (double i=5; i<=8; i+=0.125) {
float initial_rate=(float) (i*Math.pow(1200, -1));
double new_Rate= initial_rate+1;
double num_of_months=12*num_of_yrs;
double flag= (double) Math.pow(new_Rate, -num_of_months);
double answer= (amount_loan*initial_rate)/(1-flag);
jTextArea1.append(df2.format(i)+"%"+"
"+df2.format(answer)+"
"+df2.format(answer*12*num_of_yrs)+"\n");
.addGap(23, 23, 23)
.addComponent(display_button)
.addPreferredGap(javax.swing.LayoutStyle.ComponentP
lacement.RELATED)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.DEFAULT_SIZE, 320, Short.MAX_VALUE)
.addContainerGap())))
);
pack();
}
private void amount_of_loanTFActionPerformed(java.awt.event.ActionEvent
evt) {
}
public void showLoan(double amount_loan, double num_of_yrs) {
DecimalFormat df2 = new DecimalFormat("#.00");
jTextArea1.append("Interest rate "+"Monthly Payment
"+"Total Payment \n");
for (double i=5; i<=8; i+=0.125) {
float initial_rate=(float) (i*Math.pow(1200, -1));
double new_Rate= initial_rate+1;
double num_of_months=12*num_of_yrs;
double flag= (double) Math.pow(new_Rate, -num_of_months);
double answer= (amount_loan*initial_rate)/(1-flag);
jTextArea1.append(df2.format(i)+"%"+"
"+df2.format(answer)+"
"+df2.format(answer*12*num_of_yrs)+"\n");
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

}
}
private void display_buttonActionPerformed(java.awt.event.ActionEvent
evt) {
String loanamount = amount_of_loanTF.getText();
String yrs = num_of_yrsTF.getText();
double lamt = Double.parseDouble(loanamount);
double years = Double.parseDouble(yrs);
showLoan(lamt,years);
}
private void num_of_yrsTFActionPerformed(java.awt.event.ActionEvent
evt) {
}
public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Start.class.getName()).log(java.util.log
ging.Level.SEVERE, null, ex);
}
private void display_buttonActionPerformed(java.awt.event.ActionEvent
evt) {
String loanamount = amount_of_loanTF.getText();
String yrs = num_of_yrsTF.getText();
double lamt = Double.parseDouble(loanamount);
double years = Double.parseDouble(yrs);
showLoan(lamt,years);
}
private void num_of_yrsTFActionPerformed(java.awt.event.ActionEvent
evt) {
}
public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Start.class.getName()).log(java.util.log
ging.Level.SEVERE, null, ex);
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Start.class.getName()).log(java.util.log
ging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Start.class.getName()).log(java.util.log
ging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Start.class.getName()).log(java.util.log
ging.Level.SEVERE, null, ex);
}
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Start().setVisible(true);
}
});
}
private javax.swing.JButton display_button;
private javax.swing.JLabel amtloan1;
private javax.swing.JLabel yrsLabel;
private javax.swing.JLabel jLabel3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JTextField amount_of_loanTF;
private javax.swing.JTextField num_of_yrsTF;
}
3. Screenshot
java.util.logging.Logger.getLogger(Start.class.getName()).log(java.util.log
ging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Start.class.getName()).log(java.util.log
ging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Start.class.getName()).log(java.util.log
ging.Level.SEVERE, null, ex);
}
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Start().setVisible(true);
}
});
}
private javax.swing.JButton display_button;
private javax.swing.JLabel amtloan1;
private javax.swing.JLabel yrsLabel;
private javax.swing.JLabel jLabel3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JTextField amount_of_loanTF;
private javax.swing.JTextField num_of_yrsTF;
}
3. Screenshot

4. Self-evaluation
1. User Interface is successfully developed & every single requirement
was fulfilled.
2. Values were correctly calculated as well as the output was displayed
in the box of text area.
3. Table of the output is displayed accurately & correctly.
1. User Interface is successfully developed & every single requirement
was fulfilled.
2. Values were correctly calculated as well as the output was displayed
in the box of text area.
3. Table of the output is displayed accurately & correctly.
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide
1 out of 9

Your All-in-One AI-Powered Toolkit for Academic Success.
 +13062052269
info@desklib.com
Available 24*7 on WhatsApp / Email
Unlock your academic potential
Copyright © 2020–2025 A2Z Services. All Rights Reserved. Developed and managed by ZUCOL.