home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Run Magazine ReRun 1985 Summer
/
rerun-1985-summer-side-a.d64
/
teacher
(
.txt
)
< prev
Wrap
Commodore BASIC
|
2022-09-20
|
3KB
|
99 lines
10 rem math worksheet by f. colosimo
20 rem com 64 vs 19 12/24/83
30 open1,4 :rem use approp. cmd for your printer/interface
40 rem set constants and get paper ready
50 un$=chr$(14):rem this cmd turns on dbl width
60 off$=chr$(15): rem this turns off dbl wid.
70 di$="(1-3)":x=0:poke53280,0:poke53281,12
80 dima%(28),b%(28),a$(7),b$(7),n1%(28),n2%(28),an%(42)
90 print"[144][147] ******* math worksheet *******":print" position paper now "
100 print" with perf at printhead..."
110 rem define problem characteristics
120 print" do you want addition, subtraction or multiplication?(+,-,x)"
130 geto$:ifo$=""then130
140 printspc(6)" operation = [144]"o$
150 ifo$="x"thend1$="(1-2)":goto170
160 ifo$<>"+"ando$<>"-"then120
170 print" how many digits do you want?"d1$
180 getd$:ifd$=""then180
190 d=val(d$):ifd<1ord>3then170
200 ifd>2ando$="x"then170
210 printspc(6)" problems will have "d"digits[144]"
220 ifd=1oro$="x"thenca$="y":goto270
230 print" do you want carrying/borrowing? (y/n)"
240 getca$:ifca$=""then240
250 ifca$<>"y"andca$<>"n"then230
260 printspc(7)" carry/borrow = [144]"ca$
270 ifd>1thenaa=9:goto310
280 print" what is the highest number you want in the problems? (1-9)"
290 getaa$:ifaa$=""then290
300 aa=val(aa$):ifaa<1then280
310 printspc(4)" highest number in problems =[144]"aa
320 print" do you want answers on wksht? (y/n)"
330 getan$:ifan$=""then330
340 gosub960:rem print title
350 rem ***we create 6 rows of problems
360 form=1to6
370 gosub490:gosub810:nextm:as=d
380 ifan$<>"n"then410
390 forn=1to3:print#1,chr$(13):next:goto430
400 rem *** print answers ***
410 forn=1to6:print#1,off$spc(1+as);:form=1to7:du=an%((n-1)*7+m):d=10:gosub920
420 print#1,du$;:next:print#1:next
430 print#1,chr$(13)chr$(13):close1
440 print"[147]would you like to make another worksheet?(y/n)"
450 getc$:ifc$=""then450
460 ifc$="y"thenrun
470 end
480 rem ** subroutine to create random digits
490 forn=1tod*7:a%(n)=(aa-1)*rnd(0)+2:next
500 ifca$="n"ando$="+"then570
510 forn=1tod*7:b%(n)=aa*rnd(0)+1:next
520 ifo$<>"-"then630
530 rem for minus, a% always > b%
540 forn=1tod*7:ifa%(n)<b%(n)thenc%=a%(n):a%(n)=b%(n):b%(n)=c%
550 next:goto580
560 rem ** 2nd line of digits for no carry, o$=+, and d>1
570 forn=1tod*7:b%(n)=rnd(0)*(9-a%(n))+1+(a%(n)=9):next
580 ifca$="n"then630
590 rem ** increase freq of borrows
600 forn=1tod*7stepd:c%=a%(n):a%(n)=b%(n):b%(n)=c%
610 next
620 rem ** form numbers from sep digits
630 forn=1to7:pl=0:n1%(n)=0:n2%(n)=0
640 fornn=d*(n-1)+1to(n-1)*d+d
650 n1%(n)=n1%(n)+a%(nn)*10^pl
660 n2%(n)=n2%(n)+b%(nn)*10^pl:pl=pl+1:next
670 ifo$<>"-"then710
680 rem if minus put bigger # on top
690 ifn1%(n)<n2%(n)thenc%=n1%(n):n1%(n)=n2%(n):n2%(n)=c%
700 rem calc answers
710 x=x+1
720 ifo$="+"thenan%(x)=n1%(n)+n2%(n)
730 ifo$="-"thenan%(x)=n1%(n)-n2%(n)
740 ifo$="x"thenan%(x)=n1%(n)*n2%(n)
750 next
760 rem *** send n1% and n2% for string conversion
770 forn=1to7:du=n1%(n):gosub920:a$(n)=du$
780 du=n2%(n):gosub920:b$(n)=du$:next:return
790 rem *** subroutine to print a row of problems
800 rem *** print first line (a$)
810 l=len(a$(1)):print#1,un$spc(4);:forn=1to7
820 print#1," "a$(n)spc(4-l);:next
830 rem *** print second line (b$)
840 print#1,chr$(10):print#1,un$spc(4);
850 forn=1to7:print#1,o$b$(n)spc(4-l);:next
860 rem print underline
870 print#1:print#1,un$spc(4);:forn=1to7
880 fornn=0tol:print#1,"-";:next:print#1,spc(4-l);:next
890 print#1,chr$(10)chr$(10)chr$(10)chr$(10)
900 return
910 rem subroutine to convert fl. pt. to string and adj alignment
920 du$=str$(du)
930 iflen(du$)<d+1thendu$=" "+du$:goto930
940 du$=right$(du$,d):return
950 rem subroutine to print wksht header
960 print#1,chr$(13)chr$(13)
970 print#1,un$spc(18)"name:":print#1,un$spc(23)"---------------"
980 print#1,chr$(10)un$spc(12)"math worksheet"chr$(13)chr$(13):return