I have my brackets all messed up and was wondering if someone could help me fix them. I am sure there are other errors too, so any advice would be greatly appreciated! :)
import java.util.*;
import java.awt.Container;
import java.awt.TextArea;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import javax.swing.ComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
public class DeeWeek3_J2
{
private static int total;
private static int interestPay;
public static void main(String[]args, int counter, NumberFormat moneyFormat)throws IOException
{
System.out.println("Mortgage Calculator");
}
//variables
double loanAmt = 200000.00;
int[]length = new int [3];
{
length[0]=7;
length[1]=15;
length[2]=30;
}
private JComboBox IntInterest;
private JLabel principallb, interestlb, termlb, paymentlb;
JButton calBtn;
private JButton resetBtn;
private JTextField principalTxFld, interestTxFld, termTxFld, paymentTxFld;
private TextArea payAmortTA;
String currentInt;
private JTextField payment;
{
double [] interest = new double [3]{
interest[0]=.0535,interest[1]=.0550,interest[2]=.0575};
{
int x=0;
DecimalFormat twoplaces=new DecimalFormat("#,###.00");
//Combo Items
String[] comboItems={"5.35","5.50","5.75"};
//Labels
principallb = new JLabel("Principal:");
interestlb = new JLabel("Interest:");
termlb = new JLabel("Term:");
paymentlb = new JLabel("Payment:");
//Text Field
principalTxFld = new JTextField("",10);
interestTxFld = new JTextField("",5);
interestTxFld.setEditable(true);
termTxFld = new JTextField("",5);
payment = new JTextField("",10);
payment.setEditable(true);
{
// Pull down table
IntInterest = new JComboBox(comboItems);
IntInterest.setEditable(true);
payAmortTA = new TextArea(20,40);
}
calculateMortgage();
}
{
createAndShowGui();
JFrame frame = new JFrame("Morgage Calculator");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Object calculator = new MortgageCalculator();
((JComponent) calculator).setOpaque(true);
frame.setContentPane((Container) calculator);
frame.pack();
frame.setVisible(true);}
}
private void calculateMortgage(){
}
private void createAndShowGui() {
// TODO Auto-generated method stub
}
{
};
{
//Buttons
calBtn = new JButton("Calculate");
calBtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae)
{
{
resetBtn = new JButton("Reset");
resetBtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
{
principalTxFld.setText("");
interestTxFld.setText("");
termTxFld.setText("");
monthlyPayment.setText("");
payAmortTA.setText.setText("");
}
}
{
//Adding the Labels and Fields
add(principallb);
add(principalTxFld);
add(interestlb);
add(interestTxFld);
add(termlb);
add(termTxFld);
add(paymentlb);
add(paymentTxFld);
add(payAmortTA);
add(calBtn);
add(resetBtn);
{
//Calculation for Payments
do
{
double payment=(loanAmt*(interest[x]/12))/(1-(Math.pow(1/(1+(interest[x]/12)),(length[x]*12))));
System.out.println();
System.out.print("Loan Principal Amount: $200,000.00");
System.out.print("Payment Amount:$"+twoplaces.format(payment)+"for the "+length[x]+"-Year Contract.");
x++;
}
while(x<3);
{
int amount;
for (int i=0; i<=11;i++)
interestPay=amount*interest;
amount-=(total-interestPay);
System.out.println();
System.out.print("Payment#"+counter++);
System.out.print("\tPrincipal Balance:v"+moneyFormat.format(amount));
System.out.print("\tMonth Interest:"+moneyFormat.format(interest));
System.out.println();
System.out.print("Press Y and hit enter...");
counter=1;
}
while(amount>=1)
{
//loop statement to show 12 lines at a time
for(int i=0;1<=11;i++)
{
//payment output
interestPay=amount*interest;
amount-=(total-interest);
System.out.println();
System.out.print("Payment#"+counter++);
System.out.print("\tPrincipal Balance:"+moneyFormat.format(interest));
System.out.println();
}
System.out.println();
System.out.print("Press Y and hit enter...");
}
}
}
}
}
}
}