home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 12 / 012.d81 / aras.calc (.txt) < prev    next >
Commodore BASIC  |  2022-08-26  |  4KB  |  162 lines

  1. 2 rem adjustable rate amortization schedule
  2. 10 dim r(50),mp(50),bl(50),ad(50),m$(50),b$(50),dd(50)
  3. 15 for j=0to50: ad(j)=0:next:ia=0
  4. 25 gosub500:gosub510:gosub520:gosub530
  5. 30 print:print"will there be additional payments to"
  6. 35 print"reduce the principal? (y=yes; n=no)";:inputa$
  7. 50 ifa$="y"thengosub570:goto70
  8. 60 ia=0
  9. 70 gosub300:gosub200
  10. 80 printchr$(147):print"use function keys to modify input data."
  11. 85 print:print"f1[146]...loan amount"
  12. 90 print:print"f2[146]...term of loan"
  13. 95 print:print"f3[146]...number of years to project"
  14. 100 print:print"f4[146]...interest rates"
  15. 105 print:print"f5[146]...additional payments"
  16. 110 print:print"f6[146]...display current input data"
  17. 115 print:print"f7[146]...print table"
  18. 120 print:print"f8[146]...exit"
  19. 125 get a$:ifa$=""then125
  20. 130 if a$=chr$(133)thengosub500:goto80
  21. 135 if a$=chr$(137)thengosub510:gosub530:goto80
  22. 140 if a$=chr$(134)thengosub520:goto80
  23. 145 if a$=chr$(138)thengosub530:goto80
  24. 150 if a$=chr$(135)thengosub570:goto80
  25. 155 if a$=chr$(139)thengosub700:goto80
  26. 160 if a$=chr$(136)thengosub300:gosub200:goto80
  27. 165 if a$=chr$(140)then63000
  28. 170 print:print"incorrect key typed. try again":goto80
  29. 200 jj=0:jt=10:ifia>0 thenjt=5
  30. 201 c$=" monthly":ifia=2thenc$=" yearly"
  31. 202 nm=n:ifj1>0thennm=j1
  32. 205 forj=1tonm:ifjj>0then232
  33. 210 printchr$(147);spc(12)"adjustable rate"
  34. 215 printspc(9)"amortization schedule"
  35. 220 print:printspc(13)"loan amount: $";bl(0)
  36. 225 print:printspc(13)"term:";ny;" years"
  37. 230 print:print"year   rate     payment    balance"
  38. 232 x=mp(j):gosub650:m$(j)=x$
  39. 233 x=bl(j):gosub650:b$(j)=x$
  40. 235 printj;tab(6);r(j);tab(15);"$";m$(j);tab(26);"$";b$(j)
  41. 245 ifia>0thenx=ad(j):gosub650:printtab(13);"+ $";x$;c$
  42. 250 jj=jj+1:ifjj<jtthen265
  43. 255 jj=0:gosub780
  44. 265 next:ifjj>0thengosub780
  45. 269 printchr$(147):forq=1to5:print:next
  46. 270 print"total interest paid over the projection"
  47. 275 print"period of";nm;" years";
  48. 280 ifj2>0thenprint" and";j2;" months:";
  49. 283 x=tl:gosub650
  50. 285 print:printtab(16)"$";x$
  51. 290 gosub780
  52. 295 return
  53. 300 xb=bl(0):x=xb:tl=0:j1=0:j2=0:gosub800
  54. 302 forj=1ton
  55. 303 ad(j)=dd(j)
  56. 305 ir=r(j)/12:if(ia=0 or ia=2)thenx=bl(j-1)
  57. 307 gosub450:mp(j)=x
  58. 310 ifia=1then350
  59. 315 ifia=3then410
  60. 320 x=x*(1-v^(t-12))/ir:gosub650
  61. 330 bl(j)=x-ad(j)
  62. 335 ifbl(j)<=0thenj1=j:j=n:bl(j)=0
  63. 340 tl=tl+12*mp(j)+bl(j)-bl(j-1)
  64. 345 goto395
  65. 350 for jj=1to12
  66. 355 x=xb*ir:gosub650
  67. 360 tl=tl+x:xb=xb-mp(j)+x-ad(j)
  68. 365 ifxb>0then390
  69. 370 j1=j:j2=jj
  70. 375 xb=xb+ad(j)
  71. 380 x=xb*ir:gosub650
  72. 385 tl=tl+x:bl(j)=0:jj=12:j=n
  73. 390 nextjj
  74. 391 ifj1=0thenbl(j)=xb:x=xb
  75. 395 next
  76. 400 return
  77. 410 ifmp(j)>ad(j)thenad(j)=0:goto350
  78. 415 ad(j)=ad(j)-mp(j):goto350
  79. 450 v=1/(1+ir)
  80. 455 t=(ny-j+1)*12
  81. 460 x=x*ir/(1-v^t)
  82. 465 gosub650:return
  83. 500 printchr$(147):print:print:input"amount of loan";bl(0):return
  84. 510 printchr$(147):print:print:input"term of loan in years";ny
  85. 515 nn=12*ny:return
  86. 520 printchr$(147):print:print:input"number of years to project";n:return
  87. 530 printchr$(147):print:print"enter interest rates for each year to be"
  88. 531 printchr$(145)"projected.  the entry of a negative"
  89. 532 print"number will maintain the last rate for"
  90. 533 print"the rest of the projection."
  91. 535 ij=0:forj=1ton
  92. 540 ifij>0then555
  93. 545 print"year";j;:input r(j)
  94. 550 ifr(j)>0then560
  95. 555 r(j)=r(j-1):ij=1
  96. 560 next:return
  97. 570 printchr$(147):print:print"additional payments may be made monthly"
  98. 571 print"or yearly or may be canceled."
  99. 575 print"f1[146]...additional monthly payments during"
  100. 576 printspc(5)"the year"
  101. 580 print"f3[146]...additional yearly payments"
  102. 583 print"f5[146]...set a total monthly payment"
  103. 584 print"f7[146]...no additional payments"
  104. 585 geta$:ifa$=""then585
  105. 590 ifa$=chr$(133)thenia=1:goto600
  106. 591 ifa$=chr$(134)thenia=2:goto600
  107. 592 ifa$=chr$(136)thenia=0:goto640
  108. 595 ia=3:print:print"enter the total desired monthly payment."
  109. 596 printchr$(145)"if amount is less than the amount needed"
  110. 597 printchr$(145)"to amortize, the larger amount will be"
  111. 598 print"used.":goto601
  112. 600 print:print:print"enter additional amounts to be paid."
  113. 601 print"the entry of a negative number will"
  114. 602 print"maintain the last amount for the rest of"
  115. 603 printchr$(145)"the projection"
  116. 610 ij=0:forj=1ton
  117. 615 ifij>0then630
  118. 620 print"year";j;:input ad(j)
  119. 625 ifad(j)>=0then635
  120. 630 ij=1:ad(j)=ad(j-1)
  121. 635 dd(j)=ad(j):next:return
  122. 640 for j=1ton:ad(j)=0:next:return
  123. 650 xh=int(x):xl=100*x-100*xh
  124. 655 ifxl>=99.5thenxl=o:xh=xh+1:goto665
  125. 660 if xl-int(xl)>=.5thenxl=xl+1
  126. 665 xl$=str$(int(xl)):ll=len(xl$)-1:xl$=right$(xl$,ll)
  127. 670 xh$=str$(xh)
  128. 675 ifxl=0thenxl$="00":goto685
  129. 680 ifxl<10thenxl$="0"+xl$
  130. 685 x$=xh$+"."+xl$
  131. 690 x=val(x$)
  132. 695 return
  133. 700 printchr$(147);tab(91)"current input data"
  134. 705 print:print"loan amount: $";bl(0)
  135. 710 print:print"term: ";ny;" years"
  136. 715 print:print"projected for";n;" years"
  137. 717 gosub780
  138. 720 printchr$(147):print:print:print"interest rates:"
  139. 725 for j=1ton:printr(j),
  140. 730 ifj=4*int(j/4)then print
  141. 735 next
  142. 737 gosub780
  143. 740 ifia=0thenprint"no prepayments":gosub780
  144. 741 ifia=0thenforj=1ton:ad(j)=0:dd(j)=0:next:return
  145. 745 ifia=1thenprintchr$(147):print:print
  146. 747 ifia=1thenprint"additional monthly payments":goto755
  147. 750 ifia=2thenprintchr$(147):print:print
  148. 752 ifia=2thenprint"additional yearly payments":goto755
  149. 753 ifia=3thenprintchr$(147):print:print:print"total monthly payments"
  150. 755 forj=1ton
  151. 757 printdd(j),
  152. 760 ifj=4*int(j/4)then print
  153. 765 next:gosub785:return
  154. 780 print:print"hit any key to continue."
  155. 785 geta$:ifa$=""then785
  156. 790 return
  157. 800 printchr$(147);tab(206)"calculations being performed"
  158. 805 return
  159. 63000 rem    connect back to l.s.
  160. 63002 print"[147]load"chr$(34)"payload"chr$(34)",8":print"run"
  161. 63004 poke198,0:poke631,13:poke632,13:poke198,2:end
  162.