/*rexx*/ say "enter loan amount" parse pull principal /*I used this format to input the rest of the information*/ if principal =0 THEN do say "congrats you're debt-free!" exit end if principal <0 then do do until principal >0 say "loan amount must be greater than 0" say "enter loan amount" parse pull principal end end /*create two principals for roi comparison*/ principal1=principal principal2=principal say "your loan amount is " principal /*loan intrest rate*/ say "enter loan intrest rate" parse pull Irate if irate <0 then do do until irate >=0 say "intrest rate must be greater than 0" say "enter intrest rate" parse pull irate end end say "your intrest rate is " irate "%" /*loan term in years*/ say "enter your loan term in whole years " parse pull time if time <1 then do until time >=1 say " term in years must be greater than 0" say "enter your loan term in years" parse pull time end rate= ((irate/100)/12) /*periodic intrest rate*/ /*roi loop*/ time=time*12 payment = principal1*((rate*(1+rate)**time)/(((1+rate)**time)-1)) totali1 =0 do until principal1 <=payment intrest = rate* principal1 totali1= totali1+intrest principal1 = principal1+intrest -payment end intrest = rate* principal1 payment= principal1+intrest totali1= totali1 +intrest principal1 = principal1+intrest -payment /*loop end*/ /*optional addtional payments*/ say "youre on track to pay "totali1" in intrest ,how much extra would you like to pay each month ?(Enter zero if none)" parse pull addpay say "would you like your payment details to be executed to html(1) or excel((2)" parse pull datatype if datatype = 1 then do outfile = "loan_report.html" call lineout outfile, "" call lineout outfile, "
" call lineout outfile, "| Payment # | Beginning Balance | Scheduled Payment | Extra Payment | Total Payment | Interest | Ending Balance | Total Interest |
|---|---|---|---|---|---|---|---|
| "count" | "trunc(principal2,2)" | "trunc(payment,2)" | "addpay" | "trunc(payment+addpay,2)" | "trunc(intrest,2)" | "trunc(endbal,2)" | "trunc(totali,2)" |
| "count" | "trunc(principal2,2)" | "trunc(payment,2)" | "addpay" | "trunc(payment+addpay,2)" | "trunc(intrest,2)" | "trunc(endbal,2)" | "trunc(totali,2)" |
Total payments made: " trunc(totalp, 2) "
" call lineout outfile, "Total interest paid: " trunc(totali, 2) "
" if addpay > 0 then call lineout outfile, "Extra paid: " trunc(totala, 2) " over " count " months. Interest saved: " save ". ROI: " roi "%
" call lineout outfile, "" end if datatype = 2 then do call lineout outfile, "" call lineout outfile, "Final Summary" call lineout outfile, "Total payments made," trunc(totalp, 2) call lineout outfile, "Total interest paid," trunc(totali, 2) if addpay > 0 then call lineout outfile, "Extra paid," trunc(totala, 2) ",Months," count ",Interest saved," save ",ROI," roi "%" end /* make sure to close output file */ call lineout outfile, , 1