Results 1 to 4 of 4
  1. #1
    scooter24 is offline Member
    Join Date
    Jun 2011
    Posts
    4
    Rep Power
    0

    Default mortgage calculator

    I am trying to figure out what i am doing wrong. I should get $1167.15 for monthly payment but I do not. Below is my source code. Thanks in advance.

    import java.text.*; // import text editor
    import java.io.*; // import input/output
    import java.math.*; // import math calculation

    public class MortgageCalculator
    {
    public static void main(String[] args)
    {
    double interest = 5.75;
    int mortgageAmount = 200000;
    int years = 360;
    double intcalc = (5.75/100.12);
    double monthlyPayment = 0;

    monthlyPayment = mortgageAmount * (intcalc/ (1-Math.pow((1+intcalc),-1* (years*12))));

    System.out.println("The amount of your mortgage is " + mortgageAmount + "\n" +
    " your interest rate is " + interest + "\n" + " length of mortgage is " + years +
    "\n" + " and your monthly payment is " + monthlyPayment);

    }
    }

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    What do you get? Have you tried breaking up the formula into several smaller calculations.

  3. #3
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,015
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by scooter24 View Post
    double intcalc = (5.75/100.12);
    What is the meaning of 100.12?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    scooter24 is offline Member
    Join Date
    Jun 2011
    Posts
    4
    Rep Power
    0

    Default

    Quote Originally Posted by JosAH View Post
    What is the meaning of 100.12?

    kind regards,

    Jos
    my apologies I changed it, it is suppose to be
    double intcalc = (5.75/100/12);

    sunde887
    I get 958.3333343639343

Similar Threads

  1. Mortgage Monthly Payment Formula
    By EpyonCustom in forum New To Java
    Replies: 5
    Last Post: 04-28-2011, 12:21 AM
  2. monthly mortgage payment formula
    By leoshiner in forum New To Java
    Replies: 2
    Last Post: 04-22-2011, 01:46 PM
  3. Mortgage Calculator
    By rsmithjr316 in forum New To Java
    Replies: 14
    Last Post: 01-21-2011, 10:53 PM
  4. Mortgage Calculator
    By pablo2002 in forum Java Applets
    Replies: 3
    Last Post: 09-25-2010, 10:34 PM
  5. mortgage calculator help
    By kalibballer in forum New To Java
    Replies: 1
    Last Post: 03-26-2009, 11:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •