theres a couple things wrong with this and i have no clue where to start. like the title says it has to be a really simple mortgage calculator, no gui or any other inputs. not yet atleast. my prof messaged me back saying i need
"1. import goes before public class
2. DecimalFormat num = new DecimalFormat(“$,###.00“); is a declaration so goes with the other declarations at the top of your program
3. When you want to print out you monthly payment you use num.format(mp) to get it to be in the right format"
other than those 3 things nothing else should need to be added, only corrected to get the right answer. which is 665.30 BTW
any help would be greatly appreciated

//lab 2
//File: MortgagePayment.java
//Programmer: Edward MacConnell

import java.text.*;  //for DecimalFormat class
public class MortgagePayment

{

    public static void main(String[] args)

    {
      double mp,   //mortgage payment per month
               p;    //total amout owed
        double I;    //interest 
        int T;    //time for the mortgage
        p=100000;    //assign value to total amoun owed 
        I=0.07;       //assign value to interest
        T=30;        //assign value to time of the mortgage
       mp= p*((I/12.0)/(1-(1/(1+I))*(T*12)));     //compute mortgage payment
      System.out.println("mp is " +mp);  //output monthly mortgage payment (mp) using num format    }
   }
}
Member Avatar for iamthwee

Assuming it yields the right answer, btw, you didn't mention this you want to take the user input from the command line so this is more useful.

That way they can specify 'p' and 'I' etc.

Google user input in java for ideas.

theres a couple things wrong with this

it might be best if you told us how you know this. do you get a compile time, or runtime exception? if so, show the stacktrace. do you get an output you don't expect? then tell us what it is you do expect and what you get.

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.