# Cobol equation help!

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

1. ### 3870x2

Joined:
Feb 26, 2008
Messages:
4,876 (1.68/day)
690
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%)

Well, that was a rather large image. It was taken on my phone.

Last edited: Dec 3, 2012
2. ### Drone

Joined:
Sep 1, 2010
Messages:
3,867 (1.94/day)
3,026
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.

3870x2 says thanks.
3. ### 3870x2

Joined:
Feb 26, 2008
Messages:
4,876 (1.68/day)
690
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

Joined:
Sep 1, 2010
Messages:
3,867 (1.94/day)