0

I'm working on outputting a graduated payment schedule that increases every 24 months. I'm having some trouble getting the payment value to increment correctly so that payment 2 is the total of the initial payment times the increment. Then, payment 3 is a total of payment 2 times the increment. For example, the first couple of payments should look like this...

Payment 1: $274.22 increase payment $13.64
Payment 2: $287.86 increase payment $15.03
Payment 3: $302.18 increase payment $15.78
Payment 4: $317.22 increase payment $16.57

and so on... The increment is .04975. The initial payment times the increment + the original payment amount becomes the payment 2. Then, the second payment times the increment + payment 2 becomes the third payment. The third payment times the increment + the third payment becomes payment 4, etc...

I was working with a loop, like this...

<cfset loopterm = 360 />
<cfset incr = .04975 />
<cfset gradinital = 274.22 />

<cfloop from="1" to="#( loopterm / 24 )#" index="i">
   <cfset newamt = newamt + ( gradinitial * incr ) />
   <cfoutput>
      #dollarformat( newamt )#
   </cfoutput>
</cfloop>

Problem is the increase is always the same amount and does not graduate.

Thank you for any help you can provide.

1 Answer 1

1

I think you're close, but you're using the same gradinitial value in every calculation, so your increase value is always the same.

<cfset loopterm = 360>
<cfset incr = .04975>
<cfset newamt = 274.22>

<cfloop from="1" to="#( loopterm / 24 )#" index="i">
  <cfoutput>
    #dollarformat(newamt)#<br />
  </cfoutput>
  <cfset newamt = newamt + ( newamt * incr ) />
</cfloop>

This produces a result set like this:

$274.22
$287.86
$302.18
$317.22
$333.00
$349.57
$366.96
$385.21
$404.38
$424.49
$445.61
$467.78
$491.05
$515.48
$541.13

It's not perfect, but hopefully that gets you on the right track.

Sign up to request clarification or add additional context in comments.

4 Comments

Using <cfset newamt += newamt * incr> makes things a little simpler
Speaking of not being perfect, is it my imagination, or is this an infinite loop?
@DanBracuk it's not infinite. From 1 to 15 in this case.
Thank you so much for your input. I thought I had tried setting the value again before the next iteration of the loop. Let me give that a try and I will select the appropriate answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.