Getting balance from code in button

前端 未结 2 1712
庸人自扰
庸人自扰 2021-01-27 05:52

I am having a little bit of trouble calculating the balance in my code.

In this program (balance = balance * (1 + interestRate). The thing is that we are

相关标签:
2条回答
  • 2021-01-27 06:02

    I wasn't allowed to edit Zafs answer to include the extra line, so here is my take. The important point being that the initialization of finalBalance is outside of the for-loop.

    finalBalance = initialBalanceSavings + initialBalanceCorporate
    For theYear = 2013 To 2016
      subtotal = finalBalance * (1 + interestRate)
      finalBalance = subTotal
    Next
    
    0 讨论(0)
  • 2021-01-27 06:08
    For TheYear = 2013 to 2016
      SubTotal = balance * (1 + interestRate)
      balance = SubTotal
    Next
    

    UPDATE

    The code block above is just to give you an IDEA of HOW to do the loop and what should be calculated INSIDE the loop. To get the actual ANSWER you MUST remember that 2013 is the CURRENT year so you would not ACTUALLY calculate the interest for that year. And key to the way in which you accomplish this is the formatting of your loop, which in reality should begin the FOLLOWING year.

    For Year = 2013 + 1 to 2016
      'blah blah blah
    Next
    
    0 讨论(0)
提交回复
热议问题