Hi, I'm just 2 weeks into computer science 1. New to the world of java.
I'm working on the Monthly Mortgage Payment program and having some problems that I don't know how to fix. Any help greatly appreciated! I'm using JEdit & Terminal on imac. Thanx.

import java.text.*;   //for Decimal format class

public class Mortgage
{
	public static void main (String[] args);
	{
DecimalFormat num=new DecimalFormat (“$,###.00”);  //declaring variables

double P= 100000;  //mortgage Principal.
double I = 0.07;  //7% mortgage Interest.
double T= 12*30;  //30 years mortgage Term.

double MP = (((P*(I/12)) / (1-Math.pow((1/(1+I/12)),(T));  //Monthly Mortgage Payment
                                                                                                //Display variables

		System.out.println(num.format(MP));
		System.out.println(“The Monthly Mortgage Payment is: “+MP);

	}
}

--------------------------------------------------------------------

Last login: Mon Feb 7 08:32:21 on console
tracy-dos-imac:~ tracydo$ cd desktop
tracy-dos-imac:desktop tracydo$ cd "lab2"
tracy-dos-imac:lab2 tracydo$ javac Mortgage.java
Mortgage.java:11: illegal character: \8220
DecimalFormat num=new DecimalFormat (?$,###.00?); //declaring variables
^
Mortgage.java:11: ';' expected
DecimalFormat num=new DecimalFormat (?$,###.00?); //declaring variables
^
Mortgage.java:11: illegal start of expression
DecimalFormat num=new DecimalFormat (?$,###.00?); //declaring variables
^
Mortgage.java:11: illegal character: \35
DecimalFormat num=new DecimalFormat (?$,###.00?); //declaring variables
^
Mortgage.java:11: illegal character: \35
DecimalFormat num=new DecimalFormat (?$,###.00?); //declaring variables
^
Mortgage.java:11: illegal character: \35
DecimalFormat num=new DecimalFormat (?$,###.00?); //declaring variables
^
Mortgage.java:11: illegal character: \8221
DecimalFormat num=new DecimalFormat (?$,###.00?); //declaring variables
^
Mortgage.java:11: not a statement
DecimalFormat num=new DecimalFormat (?$,###.00?); //declaring variables
^
Mortgage.java:17: ')' expected
double MP = (((P*(I/12)) / (1-Math.pow((1/(1+I/12)),(T)); //Monthly Mortgage Payment
^
Mortgage.java:17: ')' expected
double MP = (((P*(I/12)) / (1-Math.pow((1/(1+I/12)),(T)); //Monthly Mortgage Payment
^
Mortgage.java:21: illegal character: \8220
System.out.println(?The Monthly Mortgage Payment is: ?+MP);
^
Mortgage.java:21: ';' expected
System.out.println(?The Monthly Mortgage Payment is: ?+MP);
^
Mortgage.java:21: ';' expected
System.out.println(?The Monthly Mortgage Payment is: ?+MP);
^
Mortgage.java:21: ';' expected
System.out.println(?The Monthly Mortgage Payment is: ?+MP);
^
Mortgage.java:21: illegal character: \8220
System.out.println(?The Monthly Mortgage Payment is: ?+MP);
^
Mortgage.java:21: not a statement
System.out.println(?The Monthly Mortgage Payment is: ?+MP);
^
Mortgage.java:21: ';' expected
System.out.println(?The Monthly Mortgage Payment is: ?+MP);
^
17 errors

Edited 5 Years Ago by peter_budo: Keep It Clear - Do wrap your programming code blocks within [code] ... [/code] tags

Comments
That's what I like to see from first time poster. Posting question and including code done so far. Nice

1) You have some Unicode character or whatever in there. You have directional quotes. You want regular old quotes, so retype that "DecimalFormat" line and see if it gets rid of the coding error.
2) Delete the semicolon at the end of public static void main (String[] args); .
3) Please use code tags.
4) Look at any other quotes in your program and make sure they aren't slanted. See point 1.
5) Make sure you have an ending parentheses for every starting parentheses in your formula.

Edited 5 Years Ago by VernonDozier: n/a

also tell us the exact question your teacher gave you so we have a better understanding of what you are trying to write.

more info you give us the better it will help us answer this for you.

here is the code fully fixed because your a newb p.s. im 12 lol

import java.text.*;

public class Mortgage{
	public static void main (String[] args){
		DecimalFormat num=new DecimalFormat ("$,###.00");
		double P= 100000;
		double I = 0.07;
		double T= 12*30; 
		double MP = (P*(I/12)) / 1-Math.pow((1/(1+I/12)),(T));

		System.out.println(num.format(MP));
		System.out.println("The Monthly Mortgage Payment is: " + MP);
	}
}

,Your Welcome

here is the code fully fixed because your a newb p.s. im 12 lol
,Your Welcome

lol

>> p.s. im 12

This is a typo and you meant to type "13" right? Because you have to be 13 to join here, if you aren't I would have to ban you. :)

. I don't know what you are looking for but here is something. Read through your code again. You made a lot of small mistakes. Good luck!

/*
 * LET"S TRY THIS I HOPE IT HELPS
 */
import java.text.*; //for Decimal format class

public class Mortgage 
{
    static DecimalFormat DecF = new DecimalFormat("0.00");

    public static void main(String[] args)// ;
    {
        // DecimalFormat num=new DecimalFormat (“$,###.00”); //declaring
        // variables

        double P = 100000; // mortgage Principal.
        double I = 0.07; // 7% mortgage Interest.

        double T = 12 * 30; // 30 years mortgage Term.

        double MP = (((P * (I / 12)) / (1 - Math.pow((1 / (1 + I / 12)), (T))))); // Monthly
                                                                                    // Mortgage
                                                                                    // Payment
        // Display variables

        System.out.println(DecF.format(MP));
        System.out.println("The Monthly Mortgage Payment is: "
                + DecF.format(+MP));

    }
}

Edited 3 Years Ago by Reverend Jim: Fixed formatting

Also, if you need the dollar sign there just add it as a string. "$" + DecF.... Just take your time, Okay?

This article has been dead for over six months. Start a new discussion instead.