home *** CD-ROM | disk | FTP | other *** search
/ Loadstar - Compleat Programmer / comprog1.d81 / b.lender (.txt) < prev    next >
Commodore BASIC  |  2022-08-28  |  3KB  |  104 lines

  1. 10 poke 53281,15:poke53280,15:printchr$(142)
  2. 90 dim b(5),b$(5)
  3. 100 print"[147]      [176][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][174]"
  4. 101 print"      [221]                          [146][221]"
  5. 105 print"      [221]   the lender's formula   [146][221]"
  6. 110 print"      [221] present value calculator [146][221]"
  7. 112 print"      [221]    by marty matthews     [146][221]"
  8. 113 print"      [221]                          [146][221]"
  9. 115 print"      [173][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][189]"
  10. 120 print"[144]               1 - (1+r/q)^-(y*q)
  11. 125 [153]"      t =  a * lentantantantantantantantantantantantanlenlenlenlenlen
  12. 130 print"                 (r/q)"
  13. 150 b$(1)="(t) total amount......":printb$(1)
  14. 160 b$(2)="(a) payment...........":printb$(2)
  15. 170 b$(3)="(r) rate/yr (.001-.5).":printb$(3)
  16. 180 b$(4)="(y) number of years...":printb$(4)
  17. 190 b$(5)="(q) payments/year.....":printb$(5)
  18. 200 y=12:x=24:forj=1to5:gosub1000:a2$=b$(j):print ">"
  19. 210 gosub 1100:b(j)=at:next
  20. 220 tt=b(1):aa=b(2):rr=b(3):yy=b(4):qq=b(5)
  21. 230 gosub800:ifa$="a"then700
  22. 240 ifa$="t" then 750
  23. 245 ifa$="r"then600
  24. 247 ifa$="y"then500
  25. 250 print "          continue? (y/n) ":sys46374
  26. 255 wait 198,15:getb$:ifb$="y"then 100
  27. 260 ifb$="n" then goto2500
  28. 270 goto 255
  29. 500 gosub950:if a<>0 then goto 250
  30. 503 print "          working !"
  31. 505 yx=yy:y1=75:y3=.08:y2=(y1-y3)/2.
  32. 510 yy=y1:gosub900:a1=tt/x1:if a1>aa then 590
  33. 512 yy=y3:gosub900:a3=tt/x1:if a3<aa then 590
  34. 514 yy=y2:gosub900:a2=tt/x1
  35. 520 if aa<a2thena3=a2:y3=y2:y2=y2+(y1-y2)/2:yy=y2:gosub900:a2=tt/x1:goto570
  36. 530 if aa>a2thena1=a2:y1=y2:y2=y2-(y2-y3)/2:yy=y2:gosub900:a2=tt/x1:goto570
  37. 540 print "        years   ";y2:yy=yx:b(4)=y2:goto250
  38. 570 if (y1-y3)<.0001    then 540
  39. 575 goto520
  40. 590 print "payment out of range for years!":goto250
  41. 600 gosub950:if a=1 then goto 250
  42. 603 print "               working !"
  43. 605 rx=rr:r1=.5:r3=.001:r2=(r1-r3)/2.
  44. 610 rr=r1:gosub900:a1=tt/x1:if a1<aa then 690
  45. 612 rr=r3:gosub900:a3=tt/x1:if a3>aa then 690
  46. 614 rr=r2:gosub900:a2=tt/x1
  47. 620 if aa>a2thena3=a2:r3=r2:r2=r2+(r1-r2)/2:rr=r2:gosub900:a2=tt/x1:goto670
  48. 630 if aa<a2thena1=a2:r1=r2:r2=r2-(r2-r3)/2:rr=r2:gosub900:a2=tt/x1:goto670
  49. 640 print "        rate    ";r2:rr=rx:b(3)=r2:goto250
  50. 670 if (r1-r3)<.00001   then 640
  51. 675 goto620
  52. 690 print "payment out of range for rate!":goto250
  53. 700 gosub950:if a<>0 then goto 250
  54. 710 gosub900
  55. 720 aa=tt/x1:print "       payment";aa
  56. 730 b(2)=aa:goto250
  57. 750 gosub950:if a<>0 then goto 250
  58. 760 gosub900:tt=aa*x1:print "       total amount ";tt
  59. 770 b(1)=tt:goto250
  60. 800 print:print "solve for (select a,t,r,y): ";
  61. 805 wait198,15:geta$:goto885
  62. 810 print "     ";a$;""
  63. 820 return
  64. 885 if(a$= "r"or a$= "t"or a$= "a"or a$ ="y") then810
  65. 890 goto805
  66. 900 x1=(1-((1+rr/qq)^(-yy*qq)))/(rr/qq)
  67. 910 if x1 = 0 then print "calculation error! check variables!":a=3:goto250
  68. 950 a=0:if qq=0 then a1$="pmts/yr ":gosub970:a=1:return
  69. 955 if a$="r"then 965
  70. 960 if rr=0 then a1$="rate/yr ":gosub970:a=2:return
  71. 965 return
  72. 970 print "missing variable for: ";a1$
  73. 980 return
  74. 1000 poke 214,y+j:poke211,x:print"[145]";:return
  75. 1100 rem get routine
  76. 1110 a1$=""
  77. 1120 get a$:if a$="" then 1120
  78. 1130 a=asc(a$):if a=20 thengosub1300:goto1190
  79. 1140 if a=13then 1200
  80. 1150 if a$="."ora$="," then1180
  81. 1160 if a$ = "-" and len(a1$) = 0 then 1180
  82. 1165 if a$ = "*" and len(a1$) = 0 then a1$=str$(b(j)):gosub1195:at=b(j):return
  83. 1170 if a < 48 or a > 60 then 1120
  84. 1180 a1$=a1$+a$
  85. 1190 gosub1195:goto 1120
  86. 1195 print "[145]"+a2$+":  "+a1$+" ":return
  87. 1200 dv=0:l =len(a1$):a = 0:at = 0:p = 0:an = 1
  88. 1210 for i=1 to l:a$ = mid$(a1$,i,1)
  89. 1215 if a$="-" then an=-1:goto 1260
  90. 1220 ifa$=","then 1260
  91. 1230 if a$="."thendv=1:goto 1260
  92. 1240 if dv=0 then a=val(a$):at = at*10 + a
  93. 1250 if dv=1 then p=p+1:a=val(a$):at = at + a/(10^p)
  94. 1260 next:at=at*an:return
  95. 1300 l=len(a1$):ifl=0then return
  96. 1310 l=l-1:a1$=mid$(a1$,1,l):return
  97. 2500 rem exit to loadstar               ****
  98. 2510 f$="hello connect":n$="loadstar"
  99. 2548 poke 53280,3:poke 53281,3
  100. 2550 print"[147]"tab((40-len(n$)-10)/2)"[204]oading "chr$(34)n$chr$(34)
  101. 2560 print"[159]new":print"load"chr$(34)f$chr$(34)",8,1"
  102. 2562 print"?c[200](144)c[200](142):run"
  103. 2570 poke198,3:poke631,13:poke632,13:poke633,13:end
  104.