To run the sample:
Select this method |
|
setPrincipalAmount | /* If an input value has changed, remember to recalculate */
if (fieldPrincipalAmount != oldValue) recalculationNeeded = true; |
setAmortizationPeriod | /* If an input value has changed, remember to recalculate */
if (fieldAmortizationPeriod != oldValue) recalculationNeeded = true; |
setInterestRate | /* If an input value has changed, remember to recalculate */
if (fieldInterestRate != oldValue) recalculationNeeded = true; /* Scale double to percentage, if necessary. */ /* This allows the interest rate to be specified as .10 to represent 10%, */ /* or as 10 to represent 10%.*/ if (fieldInterestRate > 1.0d) fieldInterestRate = fieldInterestRate / 100d; |
setPaymentsPerYear | /* If an input value has changed, remember to recalculate */
if (fieldPaymentsPerYear != oldValue) recalculationNeeded = true; |
setTimesPerYear | /* If an input value has changed, remember to recalculate */
if (fieldTimesPerYear != oldValue) recalculationNeeded = true; |
Select this method | Add this code... |
getPaymentAmount | /* If any input value has changed since last recalc, then recalc */
if (recalculationNeeded) recalculate(); |
getEffectiveAnnualRate | /* If any input value has changed since last recalc, then recalc */
if (recalculationNeeded) recalculate(); |
getTotalInterestCost | /* If any input value has changed since last recalc, then recalc */
if (recalculationNeeded) recalculate(); |
getInterestRatePerPayment | /* If any input value has changed since last recalc, then recalc */
if (recalculationNeeded) recalculate(); |
Close the class browser for CompoundInterest, and you're done!