Hi, I am a novice in programming and need help in my mortgage calculation program. I have the GUI set up all functioning good the only problem I have is the calculation portion that is not doing its job.
Can anyone please guide me how to correct my problem?

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.DecimalFormat;
import java.util.*;
import java.lang.*;
import java.text.NumberFormat;



public class week1 extends JFrame implements ActionListener
{


//declaring fields for GUI
JTextField mortgageAmountField, interestRateField, yearsTermField, monthlyPayField;JButton monthButton;
JFrame frame;
int buttonCount = 0;
DecimalFormat fmt = new DecimalFormat("0.00");


//assigning labels to the fields
JLabel mortgageAmountLabel = new JLabel("Mortgage Amount:");
JLabel interestRateLabel = new JLabel("Interest Rate:");
JLabel yearsTermLabel=new JLabel("Term (Years):");
JLabel monthlyPayLabel=new JLabel();



public week1()
{
//declaring the title of the program
frame = new JFrame("Mortgage Calculator - Greta Setian");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


//declaring panels 1 and 2
JPanel Panel1 = new JPanel();
JPanel Panel2 = new JPanel();


//assigning buttons to the panels
Panel1.add(mortgageAmountLabel);
mortgageAmountField = new JTextField(15);
Panel1.add(mortgageAmountField);


Panel1.add(interestRateLabel);
interestRateField = new JTextField(5);
Panel1.add(interestRateField);


Panel1.add(yearsTermLabel);
yearsTermField = new JTextField(5);
Panel1.add(yearsTermField);


Panel2.add(monthlyPayLabel);
monthlyPayField = new JTextField(5);
Panel2.add(monthlyPayField);


monthButton = new JButton("Reset");
monthButton.addActionListener(this);
Panel2.add(monthButton);


monthButton = new JButton("Exit");
monthButton.addActionListener(this);
Panel2.add(monthButton);


//setting up the quit button for the user to calculate the program
monthButton = new JButton("Calculate");
monthButton.addActionListener(this);
Panel2.add(monthButton);



//indicating the border layout of our frames
frame.getContentPane().add(Panel1, BorderLayout.NORTH);
frame.getContentPane().add(Panel2, BorderLayout.SOUTH);
frame.setSize(700, 100);
frame.setResizable(true);



frame.show();



}


//activating the action event so the user's input is taken
public void actionPerformed(ActionEvent event){
if(event.getSource() == monthButton)


}
public void MortgageCalcj1() {



double ortgageAmount=Double.parseDouble(mortgageAmountField.getText()); //O= Original amount of loan-hard coded
double interestRate=Double.parseDouble(interestRateField.getText()); //I=Interest rate-hard coded
double yearsTerm=Double.parseDouble(yearsTermField.getText()); //T=Term of loan- hard coded
double monthlyPay = (mortgageAmount*(interestRate / 12))/ (1 - (Math.pow(1 / (1 + (interestRate / 12)), yearsTerm)));


MortgageCalcj1 = new MortgageCalcj1(this);


//display the monthly payment
monthlyPayLabel.setText("Your Monthly Payment will be: " + fmt.format(monthlyPay));


//continue with button actionlistener
buttonCount++;
}


}



public static void main(String[] args)
{
week1 cal = new week1();
}


}
//end of programming

Hey !
Can you indent your code properly and place it in code tags ... this will make your code readable.... now its very hard to read it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.