Re: compound interest
- To: mathgroup at christensen.cybernetics.net
- Subject: [mg1758] Re: compound interest
- From: gaylord at ux1.cso.uiuc.edu (richard j. gaylord)
- Date: Wed, 26 Jul 1995 00:49:10 -0400
- Organization: university of illinois
In article <DC1EMK.4s4 at wri.com>, robert_nachbar at Merck.Com (Robert Nachbar) wrote: > does anybody have a package for computing compound interest, loan > amortizations, etc.? i've already checked mathsource to no avail. here's an interactive progam that lets you determine when you're going to get your house mortgage paid off. mayvbe you can adapt it for your own needs. -richard- ============= mortgage := (monthset = Thread[{January, February, March, April, May, June, July, August, September, October, November, December} -> Range[12]]; startyear = Input["Enter the year the loan is made:"]; startmonthname = Input["Enter the month the loan is made (January, February, March, April, May, June, July, August, September, October, November, December):"]; startmonth = startmonthname /. monthset; Print["The loan starts in ", startmonthname, " ", startyear]; nyears = Input["Enter the term of the loan (years):"]; Print["The loan is for ", nyears " years"]; npy = Input["Enter the number of payments per year:"]; Print["There are ", npy, " payments per year"]; interest = Input["Enter the annual interest rate (percent):"]/100; Print["The annual interest rate is ", interest 100, " %"]; principal= Input[" Enter the principal: "]; Print["The principal is $", principal]; n = N[npy] nyears; r = 1. + interest / N[npy]; payment = principal r^n (1 - r) / (1 - r^n); Print[]; Print["The monthly payment is $", payment]; extrapayment = Input["How much extra do you want to pay towards the principal each month?"]; Print["The extra payment is $", extrapayment]; Print["The total monthly payment is $", payment + extrapayment ]; Print["The total amount paid over the life of the loan is $", n payment]; i = 1; newprin = principal; While[newprin > 0, moprinred = payment - ((newprin interest)/12); newprin = newprin - moprinred - extrapayment; If[Mod[i, 12] == 0, Print["in ", startmonth /. Map[Reverse, monthset], " of ", startyear + (i/12), " , the remaining principal will be $", newprin] ]; i++ ]; Print["in ", (startmonth+Mod[i, 12]-1)/.Map[Reverse, monthset], " of ", startyear + Floor[i/12], " the mortgage will be paid off"] ) -- "if you're not programming functionally, then you're programming dysfunctionally"