Object-Oriented Software Development Project: Loan Comparison

Verified

Added on  2025/05/02

|8
|297
|246
AI Summary
Desklib provides solved assignments and past papers to help students succeed.
Document Page
MITS4002
OBJECT-ORIENTED SOFTWARE
DEVELOPMENT
Activity 09
Project: Comparing loans with various interest rates
Student ID:
Student full name:
Total Points (20 pts):
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Contents
Design........................................................................................................................................3
Coding........................................................................................................................................3
Screenshot..................................................................................................................................8
Document Page
Coding
package LoanComparisonAct09;
import java.text.DecimalFormat;
public class ComparingLoans extends javax.swing.JFrame {
public ComparingLoans() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
resultOutput = new javax.swing.JTextArea();
moneyTF = new javax.swing.JTextField();
yearsTF = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("Loand Amount");
jLabel2.setText("Years");
Document Page
jButton1.setText("Calculate");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
resultOutput.setColumns(20);
resultOutput.setRows(5);
jScrollPane1.setViewportView(resultOutput);
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(22, 22, 22)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEAD
ING, false)
.addComponent(jLabel2)
.addComponent(jLabel1)
.addComponent(jButton1)
.addComponent(moneyTF, javax.swing.GroupLayout.DEFAULT_SIZE, 103,
Short.MAX_VALUE)
.addComponent(yearsTF))
.addGap(46, 46, 46)
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 397,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(17, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(23, 23, 23)
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(moneyTF, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(15, 15, 15)
.addComponent(jLabel2)
.addGap(22, 22, 22)
.addComponent(yearsTF, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(32, 32, 32)
.addComponent(jButton1)
.addContainerGap(94, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1)
.addContainerGap())
);
pack();
Document Page
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String invstmnt = moneyTF.getText();
String yrstotal = yearsTF.getText();
double a = Double.parseDouble(invstmnt);
double y = Double.parseDouble(yrstotal);
compLoan(a,y);
}
public void compLoan(double money, double totyears) {
resultOutput.append("Rate of Interest "+"Monthly Payment
"+"Total Payment \n");
for (double p=5; p<=8; p+=0.125) {
float rate_initial=(float) (p*Math.pow(1200, -1));
double updatedrate= rate_initial+1;
double totmnths=totyears*12;
double variable1= (double) Math.pow(updatedrate, -totmnths);
double finalvalue= (money*rate_initial)/(1-variable1);
DecimalFormat format = new DecimalFormat("#.000");
resultOutput.append(format.format(p)+"%"+"
"+format.format(finalvalue)+" "+format.format(finalvalue*12*totyears)
+"\n");
}
Document Page
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ComparingLoans().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextField moneyTF;
private javax.swing.JTextArea resultOutput;
private javax.swing.JTextField yearsTF;
// End of variables declaration
}
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Screenshot
chevron_up_icon
1 out of 8
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]