# Cobol equation help!



## 3870x2 (Dec 3, 2012)

I need help getting a mortgage calculation working on COBOL, the image has what I need exactly, and this is what I have currently:


```
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.


----------



## Drone (Dec 3, 2012)

*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 (Dec 4, 2012)

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.


----------



## Drone (Dec 4, 2012)

I see now. There are so many different mortgage formulas. Good to know you've fixed that.


----------

