MITS4002 Object-Oriented Software Development Activity 09 Project

Verified

Added on  2025/05/02

|11
|426
|321
AI Summary
Desklib provides solved assignments and past papers to help students.
Document Page
MITS4002
OBJECT-ORIENTED SOFTWARE
DEVELOPMENT
Activity 09
Project: Comparing loans with various interest rates
Student ID:
Student full name:
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
Total Points (20 pts):
Contents
Design........................................................................................................................................3
Coding........................................................................................................................................4
Screenshot................................................................................................................................10
Document Page
Design
Figure 1: Wireframe sketch
Document Page
Coding
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
package activity09;
import java.text.DecimalFormat;
public class Frame extends javax.swing.JFrame {
/**
* Creates new form Frame
*/
public Frame() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jInternalFrame1 = new javax.swing.JInternalFrame();
jScrollPane1 = new javax.swing.JScrollPane();
showResult = new javax.swing.JTextArea();
jLabel2 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
loanTextField = new javax.swing.JTextField();
yearsTextField = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jInternalFrame1.setVisible(true);
Document Page
showResult.setColumns(20);
showResult.setRows(5);
jScrollPane1.setViewportView(showResult);
jLabel2.setText("Number of years");
jLabel1.setText("Loan");
loanTextField.addActionListener(new
java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
loanTextFieldActionPerformed(evt);
}
});
yearsTextField.addActionListener(new
java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
yearsTextFieldActionPerformed(evt);
}
});
jButton1.setText("Calculate");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
javax.swing.GroupLayout jInternalFrame1Layout = new
javax.swing.GroupLayout(jInternalFrame1.getContentPane());
Document Page
jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout);
jInternalFrame1Layout.setHorizontalGroup(
jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jInternalFrame1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1)
.addContainerGap())
.addGroup(jInternalFrame1Layout.createSequentialGroup()
.addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayou
t.Alignment.LEADING)
.addGroup(jInternalFrame1Layout.createSequentialGroup()
.addGap(81, 81, 81)
.addComponent(loanTextField,
javax.swing.GroupLayout.PREFERRED_SIZE, 99,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jInternalFrame1Layout.createSequentialGroup()
.addGap(109, 109, 109)
.addComponent(jLabel1,
javax.swing.GroupLayout.PREFERRED_SIZE, 45,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 216,
Short.MAX_VALUE)
.addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayou
t.Alignment.LEADING, false)
.addComponent(jLabel2,
javax.swing.GroupLayout.DEFAULT_SIZE, 105, Short.MAX_VALUE)
.addComponent(yearsTextField))
.addGap(81, 81, 81))
.addGroup(jInternalFrame1Layout.createSequentialGroup()
.addGap(246, 246, 246)
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(jButton1)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
);
jInternalFrame1Layout.setVerticalGroup(
jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jInternalFrame1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayou
t.Alignment.BASELINE)
.addComponent(loanTextField,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(yearsTextField,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayou
t.Alignment.BASELINE)
.addComponent(jLabel2,
javax.swing.GroupLayout.PREFERRED_SIZE, 26,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1,
javax.swing.GroupLayout.PREFERRED_SIZE, 26,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton1)
.addGap(21, 21, 21)
Document Page
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 126,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jInternalFrame1)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jInternalFrame1)
);
pack();
}// </editor-fold>
private void loanTextFieldActionPerformed(java.awt.event.ActionEvent
evt) {
// TODO add your handling code here:
}
private void yearsTextFieldActionPerformed(java.awt.event.ActionEvent
evt) {
// TODO add your handling code here:
}
Document Page
public void calculate(double loan, double totalyrs) {
showResult.append("Interest rate "+"Monthly Payment
"+"Total Payment \n");
for (double k=5; k<=8; k+=0.125) {
float beginrate=(float) (k*Math.pow(1200, -1));
//double rrate= beginrate+1;
double totalmnths=12*totalyrs;
double value= (double) Math.pow(beginrate +1 , -totalmnths);
double finalans= (loan*beginrate)/(1-value);
DecimalFormat dformat = new DecimalFormat("#.00");
showResult.append(dformat.format(k)+"%"+"
"+dformat.format(finalans)+"
"+dformat.format(finalans*12*totalyrs)+"\n");
}
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
double loanamtt = Double.parseDouble(loanTextField.getText());
double yearss = Double.parseDouble(yearsTextField.getText());
calculate(loanamtt,yearss);
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Frame().setVisible(true);
}
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
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JInternalFrame jInternalFrame1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextField loanTextField;
private javax.swing.JTextArea showResult;
private javax.swing.JTextField yearsTextField;
// End of variables declaration
}
Screenshot
Figure 2: Application
chevron_up_icon
1 out of 11
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]