Announcement

Collapse
No announcement yet.

Java math problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Java math problem

    I can't get my mortgage program to display the right amount for a mortgage payment..I keep getting 11500 a month for a 200K Mortgage :lol:

    Code:
    import java.io.*;
    
    
    public class mortgage
    {
    		public static void main(String[] args) throws IOException
    		{
    		// declaring variables
    		final double principle = 200000.00;
    		final double interest = .0575;
    		final double term=12*30;
    
    		// declaring variables
    		final double payment = principle*(interest/(1+Math.pow(1/(1+interest),term))) ;
    
    		//displaying variables
    		System.out.println("Principle or Loan amount:"+ principle);
    		System.out.println("Interest Rate:" +interest);
    		System.out.println("Term of Loan:" + term);
    		System.out.println("Monthly Payment is:" +payment);
    }
    }
    Why is it called tourist season, if we can't shoot at them?

  • #2
    What do you expect, with 5.75% per month interest?

    - Steve

    Comment


    • #3

      .0575/12
      We have enough youth - What we need is a fountain of smart!


      i7-920, 6GB DDR3-1600, HD4870X2, Dell 27" LCD

      Comment


      • #4
        Should come out to "1167.15" without tax and insurance.

        Comment


        • #5
          Is that the right equation?

          I found

          Notice where they subtracted in the denominator, while you added. In addition to everyone else pointing out annual vs monthly rate.
          Last edited by Wombat; 3 October 2005, 23:35.
          Gigabyte P35-DS3L with a Q6600, 2GB Kingston HyperX (after *3* bad pairs of Crucial Ballistix 1066), Galaxy 8800GT 512MB, SB X-Fi, some drives, and a Dell 2005fpw. Running WinXP.

          Comment


          • #6
            This is what I have to work with:

            Math to be used to calculate a payment:

            Interest Rate (5.75 would be .0575)

            Years (Number of Years in Loan)

            Loan Amount – the amount borrowed

            Rate = (1 + (Rate/12.0))

            Payment = (Loan Amount*(Rate-1))/(1-(Math.pow(Rate,-(Years*12))))

            Math.pow raises a number to a power
            Why is it called tourist season, if we can't shoot at them?

            Comment


            • #7
              check out how the pmt() function in excel works.. it is made to do exactly this
              We have enough youth - What we need is a fountain of smart!


              i7-920, 6GB DDR3-1600, HD4870X2, Dell 27" LCD

              Comment


              • #8
                Originally posted by tjalfe
                check out how the pmt() function in excel works.. it is made to do exactly this

                doesnt do much good in a java programing class
                Why is it called tourist season, if we can't shoot at them?

                Comment

                Working...
                X