I am trying to compile my simple java code and receive two errors.
Any help will be appreciated.
1. Java1_Week2.java:19: illegal start of expression
public Java1_Week2() {
2. Java1_Week2.java:19: ';' expected
public Java1_Week2(){
Here is my code:
import java.text.DecimalFormat;
import javax.swing.*;
public class Java1_Week2 {
public static void main(String[] args) {
JFrame mainWindow = new JFrame();
public Java1_Week2() {
// Declare method variables
double mortTerm = 30;
double mortRate = .0575;
double mortAmount = 200000;
double MT, MA, MR;
// Format the decimal place of the final number
DecimalFormat forma = new DecimalFormat("#,###0.00");
//Declare variables with amounts
MT = mortTerm*12;
MR = mortRate/12;
MA = mortAmount;
//Calculation of mortgate payment
double payment = (MA*(MR))/(1-(Math.pow(1/(1+(MR)),(MT))));
//Display amount of monthly payment
System.out.println("The monthly loan amount for a $200,000"
+ " loan at %5.75 interest rate is $" + forma.format(payment) + ".");
mainWindow.setTitle("Mortgage Calculator");
mainWindow.setSize(680,460);
mainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainWindow.setVisible(true);
}
}
}