1. Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Cobol equation help!

Discussion in 'Programming & Webmastering' started by 3870x2, Dec 3, 2012.

  1. 3870x2

    3870x2

    Joined:
    Feb 26, 2008
    Messages:
    4,875 (2.02/day)
    Thanks Received:
    689
    Location:
    Joplin, Mo
    I need help getting a mortgage calculation working on COBOL, the image has what I need exactly, and this is what I have currently:

    Code:
                   COMPUTE M ROUNDED = P * ( R / 12 ) -
                   ( P * (( R / 12)/( 1 - ( 1 + R / 12 )**(12 * N))))
    
    
    Where M = monthly payment, P = principal, R = rate (IE 0900 = 9%) and N = number of years.

    I must be getting a small number, I get 0 for M unless I enter very large numbers (IE P=999,999,999, N=99 years, and R=99%)

    [​IMG]

    Well, that was a rather large image. It was taken on my phone.
     
    Last edited: Dec 3, 2012
  2. Drone

    Drone

    Joined:
    Sep 1, 2010
    Messages:
    2,673 (1.79/day)
    Thanks Received:
    1,372
    Honestly I have no idea about COBOL nor mortgage but that formula seems wrong. Place where blah ^12*N. It's gotta be blah ^-12*N. Maybe that's why you get wrong answer.

    [​IMG]
     
    3870x2 says thanks.
  3. 3870x2

    3870x2

    Joined:
    Feb 26, 2008
    Messages:
    4,875 (2.02/day)
    Thanks Received:
    689
    Location:
    Joplin, Mo
    I have fixed it, my equation was correct, but the values that I entered were going in as 9000% instead of 9%. The answer I was getting was monthly payment = 0, so I thought that it was too low, it turns out that at 9000% the number was quite large, and the numbers were getting concatenated to be 0 when the number came out to be millions, but there was only room for 9999.99.
     
  4. Drone

    Drone

    Joined:
    Sep 1, 2010
    Messages:
    2,673 (1.79/day)
    Thanks Received:
    1,372
    I see now. There are so many different mortgage formulas. Good to know you've fixed that.
     

Currently Active Users Viewing This Thread: 1 (0 members and 1 guest)

Share This Page