Sub Math Financial Class

InterestPaymentVerify

Signature (Visual Basic / VBA)

Private Sub InterestPaymentVerify()
    'Verify that the InterestPayment function works correctly.

    Debug.Assert Approx(InterestPayment(0.1, 1, 5, 10000, 0, 0), -1000)
    Debug.Assert Approx(InterestPayment(0.1, 2, 5, 10000, 0, 0), -836.202519205254)
    Debug.Assert Approx(InterestPayment(0.1, 3, 5, 10000, 0, 0), -656.025290331035)
    Debug.Assert Approx(InterestPayment(0.1, 4, 5, 10000, 0, 0), -457.830338569393)
    Debug.Assert Approx(InterestPayment(0.1, 5, 5, 10000, 0, 0), -239.815891631587)

    Debug.Assert Approx(InterestPayment(0.1, 1, 5, 10000, 0, 1), 0)
    Debug.Assert Approx(InterestPayment(0.1, 2, 5, 10000, 0, 1), -760.184108368413)
    Debug.Assert Approx(InterestPayment(0.1, 3, 5, 10000, 0, 1), -596.386627573668)
    Debug.Assert Approx(InterestPayment(0.1, 4, 5, 10000, 0, 1), -416.209398699448)
    Debug.Assert Approx(InterestPayment(0.1, 5, 5, 10000, 0, 1), -218.014446937806)

    Debug.Assert Approx(InterestPayment(0.1, 1, 5, 10000, 2000, 0), -1000)
    Debug.Assert Approx(InterestPayment(0.1, 2, 5, 10000, 2000, 0), -803.443023046305)
    Debug.Assert Approx(InterestPayment(0.1, 3, 5, 10000, 2000, 0), -587.230348397242)
    Debug.Assert Approx(InterestPayment(0.1, 4, 5, 10000, 2000, 0), -349.396406283271)
    Debug.Assert Approx(InterestPayment(0.1, 5, 5, 10000, 2000, 0), -87.7790699579042)

    Debug.Assert Approx(InterestPayment(0.1, 1, 5, 10000, 2000, 1), 0)
    Debug.Assert Approx(InterestPayment(0.1, 2, 5, 10000, 2000, 1), -730.402748223914)
    Debug.Assert Approx(InterestPayment(0.1, 3, 5, 10000, 2000, 1), -533.84577127022)
    Debug.Assert Approx(InterestPayment(0.1, 4, 5, 10000, 2000, 1), -317.633096621156)
    Debug.Assert Approx(InterestPayment(0.1, 5, 5, 10000, 2000, 1), -79.7991545071856)

    Debug.Assert Approx(InterestPayment(0, 1, 5, 10000, 2000, 0), 0)
    Debug.Assert Approx(InterestPayment(0, 3, 5, 10000, 2000, 0), 0)
    Debug.Assert Approx(InterestPayment(0, 5, 5, 10000, 2000, 0), 0)

    Debug.Assert Approx(InterestPayment(0, 1, 5, 10000, 2000, 1), 0)
    Debug.Assert Approx(InterestPayment(0, 3, 5, 10000, 2000, 1), 0)
    Debug.Assert Approx(InterestPayment(0, 5, 5, 10000, 2000, 1), 0)

End Sub