on line 40 I have:

public void start

That is the only thing that is showing something wrong. I have addad, curly brackets with no luck and when I put a semi colon at the end everything after it shows an error. The programs opens the applet but does not initialize it.

Any suggestions??? :icon_question:

import java.awt.*;
import java.awt.event.*;

import javax.swing.AbstractButton;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

@SuppressWarnings("serial")
public class MortgageCalculator2 extends JApplet
implements ActionListener
{

private static final String Total = null;
JLabel MortgageCalculator = new JLabel("Mortgage Calculator");
JLabel principal = new JLabel("Principal");
JLabel interest = new JLabel ("Interest");
JLabel term = new JLabel ("Term");
JButton calcButton = new JButton ("Calculate");

{
		{
			final Container con = getContentPane();
			con.setLayout(new FlowLayout());
			final Font bigFont = null;
			MortgageCalculator.setFont(bigFont);
			con.add(MortgageCalculator);
			con.add(calcButton);
			calcButton.addActionListener(this);
			con.add(principal);
			con.add(interest);
			con.add(term);
			final Component totalResult = null;
			con.add(totalResult);
			
		}
	{
public void start
{
	principal.setText(principal);
	interest.setText(interest);
	term.setText(payment);
	totalResult.setText(Total);
	repaint();
}
		{
public void actionPerformed;ActionEvent e;
{
	Object source = e.getSource();
		if (source == calcButton)
		{
			String Response = JOptionPane.showInputDialog(null,"Enter amount of principal");
			String Response = JOptionPane.showInputDialog(null,"Enter amount of interest");
			String Response = JOptionPane.showInputDialog(null,"Enter amount of term");
			int[] principalLimit = {200000};
			int[] interestLimit = {5.35, 5.5, 5.75};
			int[] termLimit = {7, 15, 30};
			int principal = Integer.parseInt(response);
			int principlalFee = 0; int interestFee = 0; int termFee = 0;
			int x=0, a=0;
		}
		for (x = 200000; x>=0; --x)
			if (amount >= principal[x])
				principal = principal[x];
				payment = ((principal * Math.pow(1.0 + workRate, years * 12) * workRate) / (Math.pow(1.0 + workRate, years * 12) -1));
				x = 0;
				
				principal.setText("$ + principal + interest");
				totalResult.setText(" payment $" + payment);		
}

 }
}
		}

@Override
public void actionPerformed(final ActionEvent arg0) {
	// TODO Auto-generated method stub
	
}
}

on line 40 I have:

public void start

That is the only thing that is showing something wrong. I have addad, curly brackets with no luck and when I put a semi colon at the end everything after it shows an error. The programs opens the applet but does not initialize it.

Any suggestions??? :icon_question:

import java.awt.*;
import java.awt.event.*;

import javax.swing.AbstractButton;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

@SuppressWarnings("serial")
public class MortgageCalculator2 extends JApplet
implements ActionListener
{

private static final String Total = null;
JLabel MortgageCalculator = new JLabel("Mortgage Calculator");
JLabel principal = new JLabel("Principal");
JLabel interest = new JLabel ("Interest");
JLabel term = new JLabel ("Term");
JButton calcButton = new JButton ("Calculate");

{
		{
			final Container con = getContentPane();
			con.setLayout(new FlowLayout());
			final Font bigFont = null;
			MortgageCalculator.setFont(bigFont);
			con.add(MortgageCalculator);
			con.add(calcButton);
			calcButton.addActionListener(this);
			con.add(principal);
			con.add(interest);
			con.add(term);
			final Component totalResult = null;
			con.add(totalResult);
			
		}
	{
public void start
{
	principal.setText(principal);
	interest.setText(interest);
	term.setText(payment);
	totalResult.setText(Total);
	repaint();
}
		{
public void actionPerformed;ActionEvent e;
{
	Object source = e.getSource();
		if (source == calcButton)
		{
			String Response = JOptionPane.showInputDialog(null,"Enter amount of principal");
			String Response = JOptionPane.showInputDialog(null,"Enter amount of interest");
			String Response = JOptionPane.showInputDialog(null,"Enter amount of term");
			int[] principalLimit = {200000};
			int[] interestLimit = {5.35, 5.5, 5.75};
			int[] termLimit = {7, 15, 30};
			int principal = Integer.parseInt(response);
			int principlalFee = 0; int interestFee = 0; int termFee = 0;
			int x=0, a=0;
		}
		for (x = 200000; x>=0; --x)
			if (amount >= principal[x])
				principal = principal[x];
				payment = ((principal * Math.pow(1.0 + workRate, years * 12) * workRate) / (Math.pow(1.0 + workRate, years * 12) -1));
				x = 0;
				
				principal.setText("$ + principal + interest");
				totalResult.setText(" payment $" + payment);		
}

 }
}
		}

@Override
public void actionPerformed(final ActionEvent arg0) {
	// TODO Auto-generated method stub
	
}
}

OK I put in the () at the end and I am unsure of the second place you mean. It is still showing an error there. Thank you so much for helping me!

import java.awt.*;
import java.awt.event.*;

import javax.swing.AbstractButton;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

@SuppressWarnings("serial")
public class MortgageCalculator2 extends JApplet
implements ActionListener
{

private static final String Total = null;
JLabel MortgageCalculator = new JLabel("Mortgage Calculator");
JLabel principal = new JLabel("Principal");
JLabel interest = new JLabel ("Interest");
JLabel term = new JLabel ("Term");
JButton calcButton = new JButton ("Calculate");

{
		{
			final Container con = getContentPane();
			con.setLayout(new FlowLayout());
			final Font bigFont = null;
			MortgageCalculator.setFont(bigFont);
			con.add(MortgageCalculator);
			con.add(calcButton);
			calcButton.addActionListener(this);
			con.add(principal);
			con.add(interest);
			con.add(term);
			final Component totalResult = null;
			con.add(totalResult);
			
		}
	{
public void start ()
{
	principal.setText(principal);
	interest.setText(interest);
	term.setText(payment);
	totalResult.setText(Total);
	repaint();
}
		{
public void actionPerformed;ActionEvent e;
{
	Object source = e.getSource();
		if (source == calcButton)
		{
			String Response = JOptionPane.showInputDialog(null,"Enter amount of principal");
			String Response = JOptionPane.showInputDialog(null,"Enter amount of interest");
			String Response = JOptionPane.showInputDialog(null,"Enter amount of term");
			int[] principalLimit = {200000};
			int[] interestLimit = {5.35, 5.5, 5.75};
			int[] termLimit = {7, 15, 30};
			int principal = Integer.parseInt(response);
			int principlalFee = 0; int interestFee = 0; int termFee = 0;
			int x=0, a=0;
		}
		for (x = 200000; x>=0; --x)
			if (amount >= principal[x])
				principal = principal[x];
				payment = ((principal * Math.pow(1.0 + workRate, years * 12) * workRate) / (Math.pow(1.0 + workRate, years * 12) -1));
				x = 0;
				
				principal.setText("$ + principal + interest");
				totalResult.setText(" payment $" + payment);		
}

 }
}
		}

@Override
public void actionPerformed(final ActionEvent arg0) {
	// TODO Auto-generated method stub
	
}
}

I just added it just like you showed me. and now I have all kinds of errors. I will start working through them!

The bracket problems are hard to find because the indentation is so haphazard. I tried to format the code in NetBeans, but it came out all weird. Either it had a lot of problems parsing it due to errors or my setting are wrong. Anyway, here's your code in Java code tags.

The first obvious problem is line 39. Presumably that bracket is supposed to be an ending bracket to the one on line 23. However, it is a starting bracket, not an ending bracket, so I imagine that screws up everything right there for the rest of the program.

Lines 25 - 36 - This code isn't inside of any function. Is it supposd to be?

Line 40 - If start is a function, it needs a parameter list, even if the parameter list is empty. It still needs parentheses ().

Ditto Line 49.

import java.awt.*;
import java.awt.event.*;

import javax.swing.AbstractButton;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

@SuppressWarnings("serial")
public class MortgageCalculator2 extends JApplet
implements ActionListener
{

private static final String Total = null;
JLabel MortgageCalculator = new JLabel("Mortgage Calculator");
JLabel principal = new JLabel("Principal");
JLabel interest = new JLabel ("Interest");
JLabel term = new JLabel ("Term");
JButton calcButton = new JButton ("Calculate");

{
		{
			final Container con = getContentPane();
			con.setLayout(new FlowLayout());
			final Font bigFont = null;
			MortgageCalculator.setFont(bigFont);
			con.add(MortgageCalculator);
			con.add(calcButton);
			calcButton.addActionListener(this);
			con.add(principal);
			con.add(interest);
			con.add(term);
			final Component totalResult = null;
			con.add(totalResult);
			
		}
	{
public void start
{
	principal.setText(principal);
	interest.setText(interest);
	term.setText(payment);
	totalResult.setText(Total);
	repaint();
}
		{
public void actionPerformed;ActionEvent e;
{
	Object source = e.getSource();
		if (source == calcButton)
		{
			String Response = JOptionPane.showInputDialog(null,"Enter amount of principal");
			String Response = JOptionPane.showInputDialog(null,"Enter amount of interest");
			String Response = JOptionPane.showInputDialog(null,"Enter amount of term");
			int[] principalLimit = {200000};
			int[] interestLimit = {5.35, 5.5, 5.75};
			int[] termLimit = {7, 15, 30};
			int principal = Integer.parseInt(response);
			int principlalFee = 0; int interestFee = 0; int termFee = 0;
			int x=0, a=0;
		}
		for (x = 200000; x>=0; --x)
			if (amount >= principal[x])
				principal = principal[x];
				payment = ((principal * Math.pow(1.0 + workRate, years * 12) * workRate) / (Math.pow(1.0 + workRate, years * 12) -1));
				x = 0;
				
				principal.setText("$ + principal + interest");
				totalResult.setText(" payment $" + payment);		
}

 }
}
		}

@Override
public void actionPerformed(final ActionEvent arg0) {
	// TODO Auto-generated method stub
	
}
}

Thank you sooo much, as you can see I am not sure what I am doing. I will try your suggestions and get back to you. Thank you again

You're welcome. I took your code and cleaned it up a bit. There's still stuff for you to do and it won't compile, but there are fewer errors, the brackets are a little more reasonable, some of the variable types work better, the capitalization follows the naming conventions a little more, and it's formatted. Like I said, there's still stuff for you to do, but hopefully this'll put you a little more on track.

import java.awt.*;
import java.awt.event.*;

import javax.swing.AbstractButton;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

@SuppressWarnings("serial")
public class MortgageCalculator2 extends JApplet implements ActionListener
{
    JLabel mortgageCalculatorLabel = new JLabel("Mortgage Calculator");
    JLabel principalLabel = new JLabel("Principal");
    JLabel interestLabel = new JLabel("Interest");
    JLabel termLabel = new JLabel("Term");
    JLabel totalResultLabel = new JLabel("Total Result");
    JButton calcButton = new JButton("Calculate");
    int total = 0;
    int principal = 0;
    int interest = 0;
    int payment = 0;

    public void init()
    {
        final Container con = getContentPane();
        con.setLayout(new FlowLayout());
        final Font bigFont = null;
        mortgageCalculatorLabel.setFont(bigFont);
        con.add(mortgageCalculatorLabel);
        con.add(calcButton);
        calcButton.addActionListener(this);
        con.add(principalLabel);
        con.add(interestLabel);
        con.add(termLabel);
        con.add(totalResultLabel);
    }

    public void start()
    {
        principalLabel.setText(Integer.toString(principal));
        interestLabel.setText(Integer.toString(interest));
        termLabel.setText(Integer.toString(payment));
        totalResultLabel.setText(Integer.toString(total));
        repaint();
    }

    public void actionPerformed(ActionEvent e)
    {
        Object source = e.getSource();
        if (source == calcButton)
        {
            String response = JOptionPane.showInputDialog(null, "Enter amount of principal");
            response = JOptionPane.showInputDialog(null, "Enter amount of interest");
            response = JOptionPane.showInputDialog(null, "Enter amount of term");
            int[] principalLimit =
            {
                200000
            };
            int[] interestLimit =
            {
                5.35, 5.5, 5.75
            };
            int[] termLimit =
            {
                7, 15, 30
            };

            principal = Integer.parseInt(response);
            int principlalFee = 0;
            int interestFee = 0;
            int termFee = 0;
            int x = 0, a = 0;

            for (x = 200000; x >= 0; --x)
            {
                if (amount >= principal[x])
                {
                    principal = principal[x];
                }
            }
            payment = ((principal * Math.pow(1.0 + workRate, years * 12) * workRate) / (Math.pow(1.0 + workRate, years * 12) - 1));
            x = 0;

            principalLabel.setText("$ + principal + interest");
            totalResultLabel.setText(" payment $" + payment);
        }
    }
}
This article has been dead for over six months. Start a new discussion instead.