home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 12
/
012.d81
/
aras.calc
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-26
|
4KB
|
162 lines
2 rem adjustable rate amortization schedule
10 dim r(50),mp(50),bl(50),ad(50),m$(50),b$(50),dd(50)
15 for j=0to50: ad(j)=0:next:ia=0
25 gosub500:gosub510:gosub520:gosub530
30 print:print"will there be additional payments to"
35 print"reduce the principal? (y=yes; n=no)";:inputa$
50 ifa$="y"thengosub570:goto70
60 ia=0
70 gosub300:gosub200
80 printchr$(147):print"use function keys to modify input data."
85 print:print"f1[146]...loan amount"
90 print:print"f2[146]...term of loan"
95 print:print"f3[146]...number of years to project"
100 print:print"f4[146]...interest rates"
105 print:print"f5[146]...additional payments"
110 print:print"f6[146]...display current input data"
115 print:print"f7[146]...print table"
120 print:print"f8[146]...exit"
125 get a$:ifa$=""then125
130 if a$=chr$(133)thengosub500:goto80
135 if a$=chr$(137)thengosub510:gosub530:goto80
140 if a$=chr$(134)thengosub520:goto80
145 if a$=chr$(138)thengosub530:goto80
150 if a$=chr$(135)thengosub570:goto80
155 if a$=chr$(139)thengosub700:goto80
160 if a$=chr$(136)thengosub300:gosub200:goto80
165 if a$=chr$(140)then63000
170 print:print"incorrect key typed. try again":goto80
200 jj=0:jt=10:ifia>0 thenjt=5
201 c$=" monthly":ifia=2thenc$=" yearly"
202 nm=n:ifj1>0thennm=j1
205 forj=1tonm:ifjj>0then232
210 printchr$(147);spc(12)"adjustable rate"
215 printspc(9)"amortization schedule"
220 print:printspc(13)"loan amount: $";bl(0)
225 print:printspc(13)"term:";ny;" years"
230 print:print"year rate payment balance"
232 x=mp(j):gosub650:m$(j)=x$
233 x=bl(j):gosub650:b$(j)=x$
235 printj;tab(6);r(j);tab(15);"$";m$(j);tab(26);"$";b$(j)
245 ifia>0thenx=ad(j):gosub650:printtab(13);"+ $";x$;c$
250 jj=jj+1:ifjj<jtthen265
255 jj=0:gosub780
265 next:ifjj>0thengosub780
269 printchr$(147):forq=1to5:print:next
270 print"total interest paid over the projection"
275 print"period of";nm;" years";
280 ifj2>0thenprint" and";j2;" months:";
283 x=tl:gosub650
285 print:printtab(16)"$";x$
290 gosub780
295 return
300 xb=bl(0):x=xb:tl=0:j1=0:j2=0:gosub800
302 forj=1ton
303 ad(j)=dd(j)
305 ir=r(j)/12:if(ia=0 or ia=2)thenx=bl(j-1)
307 gosub450:mp(j)=x
310 ifia=1then350
315 ifia=3then410
320 x=x*(1-v^(t-12))/ir:gosub650
330 bl(j)=x-ad(j)
335 ifbl(j)<=0thenj1=j:j=n:bl(j)=0
340 tl=tl+12*mp(j)+bl(j)-bl(j-1)
345 goto395
350 for jj=1to12
355 x=xb*ir:gosub650
360 tl=tl+x:xb=xb-mp(j)+x-ad(j)
365 ifxb>0then390
370 j1=j:j2=jj
375 xb=xb+ad(j)
380 x=xb*ir:gosub650
385 tl=tl+x:bl(j)=0:jj=12:j=n
390 nextjj
391 ifj1=0thenbl(j)=xb:x=xb
395 next
400 return
410 ifmp(j)>ad(j)thenad(j)=0:goto350
415 ad(j)=ad(j)-mp(j):goto350
450 v=1/(1+ir)
455 t=(ny-j+1)*12
460 x=x*ir/(1-v^t)
465 gosub650:return
500 printchr$(147):print:print:input"amount of loan";bl(0):return
510 printchr$(147):print:print:input"term of loan in years";ny
515 nn=12*ny:return
520 printchr$(147):print:print:input"number of years to project";n:return
530 printchr$(147):print:print"enter interest rates for each year to be"
531 printchr$(145)"projected. the entry of a negative"
532 print"number will maintain the last rate for"
533 print"the rest of the projection."
535 ij=0:forj=1ton
540 ifij>0then555
545 print"year";j;:input r(j)
550 ifr(j)>0then560
555 r(j)=r(j-1):ij=1
560 next:return
570 printchr$(147):print:print"additional payments may be made monthly"
571 print"or yearly or may be canceled."
575 print"f1[146]...additional monthly payments during"
576 printspc(5)"the year"
580 print"f3[146]...additional yearly payments"
583 print"f5[146]...set a total monthly payment"
584 print"f7[146]...no additional payments"
585 geta$:ifa$=""then585
590 ifa$=chr$(133)thenia=1:goto600
591 ifa$=chr$(134)thenia=2:goto600
592 ifa$=chr$(136)thenia=0:goto640
595 ia=3:print:print"enter the total desired monthly payment."
596 printchr$(145)"if amount is less than the amount needed"
597 printchr$(145)"to amortize, the larger amount will be"
598 print"used.":goto601
600 print:print:print"enter additional amounts to be paid."
601 print"the entry of a negative number will"
602 print"maintain the last amount for the rest of"
603 printchr$(145)"the projection"
610 ij=0:forj=1ton
615 ifij>0then630
620 print"year";j;:input ad(j)
625 ifad(j)>=0then635
630 ij=1:ad(j)=ad(j-1)
635 dd(j)=ad(j):next:return
640 for j=1ton:ad(j)=0:next:return
650 xh=int(x):xl=100*x-100*xh
655 ifxl>=99.5thenxl=o:xh=xh+1:goto665
660 if xl-int(xl)>=.5thenxl=xl+1
665 xl$=str$(int(xl)):ll=len(xl$)-1:xl$=right$(xl$,ll)
670 xh$=str$(xh)
675 ifxl=0thenxl$="00":goto685
680 ifxl<10thenxl$="0"+xl$
685 x$=xh$+"."+xl$
690 x=val(x$)
695 return
700 printchr$(147);tab(91)"current input data"
705 print:print"loan amount: $";bl(0)
710 print:print"term: ";ny;" years"
715 print:print"projected for";n;" years"
717 gosub780
720 printchr$(147):print:print:print"interest rates:"
725 for j=1ton:printr(j),
730 ifj=4*int(j/4)then print
735 next
737 gosub780
740 ifia=0thenprint"no prepayments":gosub780
741 ifia=0thenforj=1ton:ad(j)=0:dd(j)=0:next:return
745 ifia=1thenprintchr$(147):print:print
747 ifia=1thenprint"additional monthly payments":goto755
750 ifia=2thenprintchr$(147):print:print
752 ifia=2thenprint"additional yearly payments":goto755
753 ifia=3thenprintchr$(147):print:print:print"total monthly payments"
755 forj=1ton
757 printdd(j),
760 ifj=4*int(j/4)then print
765 next:gosub785:return
780 print:print"hit any key to continue."
785 geta$:ifa$=""then785
790 return
800 printchr$(147);tab(206)"calculations being performed"
805 return
63000 rem connect back to l.s.
63002 print"[147]load"chr$(34)"payload"chr$(34)",8":print"run"
63004 poke198,0:poke631,13:poke632,13:poke198,2:end