home *** CD-ROM | disk | FTP | other *** search
/ Run Magazine ReRun 1985 Summer / rerun-1985-summer-side-b.d64 / teacher (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  3KB  |  99 lines

  1. 10 rem math worksheet by f. colosimo
  2. 20 rem com 64 vs 19   12/24/83
  3. 30 open1,4   :rem use approp. cmd for your printer/interface
  4. 40 rem set constants and get paper ready
  5. 50 un$=chr$(14):rem this cmd turns on dbl width
  6. 60 off$=chr$(15): rem this turns off dbl wid.
  7. 70 di$="(1-3)":x=0:poke53280,0:poke53281,12
  8. 80 dima%(28),b%(28),a$(7),b$(7),n1%(28),n2%(28),an%(42)
  9. 90 print"[144][147]    ******* math worksheet *******":print"  position paper now "
  10. 100 print"    with perf at printhead..."
  11. 110 rem define problem characteristics
  12. 120 print"   do you want addition, subtraction        or multiplication?(+,-,x)"
  13. 130 geto$:ifo$=""then130
  14. 140 printspc(6)" operation = [144]"o$
  15. 150 ifo$="x"thend1$="(1-2)":goto170
  16. 160 ifo$<>"+"ando$<>"-"then120
  17. 170 print"  how many digits do you want?"d1$
  18. 180 getd$:ifd$=""then180
  19. 190 d=val(d$):ifd<1ord>3then170
  20. 200 ifd>2ando$="x"then170
  21. 210 printspc(6)" problems will have "d"digits[144]"
  22. 220 ifd=1oro$="x"thenca$="y":goto270
  23. 230 print"  do you want carrying/borrowing? (y/n)"
  24. 240 getca$:ifca$=""then240
  25. 250 ifca$<>"y"andca$<>"n"then230
  26. 260 printspc(7)" carry/borrow = [144]"ca$
  27. 270 ifd>1thenaa=9:goto310
  28. 280 print" what is the highest number you want in  the problems? (1-9)"
  29. 290 getaa$:ifaa$=""then290
  30. 300 aa=val(aa$):ifaa<1then280
  31. 310 printspc(4)" highest number in problems =[144]"aa
  32. 320 print" do you want answers on wksht? (y/n)"
  33. 330 getan$:ifan$=""then330
  34. 340 gosub960:rem  print title
  35. 350 rem ***we create 6 rows of problems
  36. 360 form=1to6
  37. 370 gosub490:gosub810:nextm:as=d
  38. 380 ifan$<>"n"then410
  39. 390 forn=1to3:print#1,chr$(13):next:goto430
  40. 400 rem *** print answers ***
  41. 410 forn=1to6:print#1,off$spc(1+as);:form=1to7:du=an%((n-1)*7+m):d=10:gosub920
  42. 420 print#1,du$;:next:print#1:next
  43. 430 print#1,chr$(13)chr$(13):close1
  44. 440 print"[147]would you like to make another worksheet?(y/n)"
  45. 450 getc$:ifc$=""then450
  46. 460 ifc$="y"thenrun
  47. 470 end
  48. 480 rem ** subroutine to create random digits
  49. 490 forn=1tod*7:a%(n)=(aa-1)*rnd(0)+2:next
  50. 500 ifca$="n"ando$="+"then570
  51. 510 forn=1tod*7:b%(n)=aa*rnd(0)+1:next
  52. 520 ifo$<>"-"then630
  53. 530 rem for minus, a% always > b%
  54. 540 forn=1tod*7:ifa%(n)<b%(n)thenc%=a%(n):a%(n)=b%(n):b%(n)=c%
  55. 550 next:goto580
  56. 560 rem ** 2nd line of digits for no carry, o$=+, and d>1
  57. 570 forn=1tod*7:b%(n)=rnd(0)*(9-a%(n))+1+(a%(n)=9):next
  58. 580 ifca$="n"then630
  59. 590 rem ** increase freq of borrows
  60. 600 forn=1tod*7stepd:c%=a%(n):a%(n)=b%(n):b%(n)=c%
  61. 610 next
  62. 620 rem ** form numbers from sep digits
  63. 630 forn=1to7:pl=0:n1%(n)=0:n2%(n)=0
  64. 640 fornn=d*(n-1)+1to(n-1)*d+d
  65. 650 n1%(n)=n1%(n)+a%(nn)*10^pl
  66. 660 n2%(n)=n2%(n)+b%(nn)*10^pl:pl=pl+1:next
  67. 670 ifo$<>"-"then710
  68. 680 rem if minus put bigger # on top
  69. 690 ifn1%(n)<n2%(n)thenc%=n1%(n):n1%(n)=n2%(n):n2%(n)=c%
  70. 700 rem calc answers
  71. 710 x=x+1
  72. 720 ifo$="+"thenan%(x)=n1%(n)+n2%(n)
  73. 730 ifo$="-"thenan%(x)=n1%(n)-n2%(n)
  74. 740 ifo$="x"thenan%(x)=n1%(n)*n2%(n)
  75. 750 next
  76. 760 rem *** send n1% and n2% for string conversion
  77. 770 forn=1to7:du=n1%(n):gosub920:a$(n)=du$
  78. 780 du=n2%(n):gosub920:b$(n)=du$:next:return
  79. 790 rem *** subroutine to print a row of problems
  80. 800 rem *** print first line (a$)
  81. 810 l=len(a$(1)):print#1,un$spc(4);:forn=1to7
  82. 820 print#1," "a$(n)spc(4-l);:next
  83. 830 rem *** print second line (b$)
  84. 840 print#1,chr$(10):print#1,un$spc(4);
  85. 850 forn=1to7:print#1,o$b$(n)spc(4-l);:next
  86. 860 rem print underline
  87. 870 print#1:print#1,un$spc(4);:forn=1to7
  88. 880 fornn=0tol:print#1,"-";:next:print#1,spc(4-l);:next
  89. 890 print#1,chr$(10)chr$(10)chr$(10)chr$(10)
  90. 900 return
  91. 910 rem subroutine to convert fl. pt. to string and adj alignment
  92. 920 du$=str$(du)
  93. 930 iflen(du$)<d+1thendu$=" "+du$:goto930
  94. 940 du$=right$(du$,d):return
  95. 950 rem subroutine to print wksht header
  96. 960 print#1,chr$(13)chr$(13)
  97. 970 print#1,un$spc(18)"name:":print#1,un$spc(23)"---------------"
  98. 980 print#1,chr$(10)un$spc(12)"math worksheet"chr$(13)chr$(13):return
  99.