10 REM "SUB 1.6, COPYRIGHT 1983"
30 REM "By SmallSoft"
35 CLS$=CHR$(26):CH$=CHR$(27)
40 PRINT CHR$(26):FOR I=1 TO 7:PRINT:NEXT
50 PRINT "        WELCOME TO SUBtraction ";USER$
80 PRINT:PRINT "Yes, this is SUBtraction. In this sub-program of" 
90 PRINT "KIDMATH, you will be able to work subtraction "
100 PRINT "problems at any of five (5) levels of hardness."
105 COMMON SEED
110 CHAIN MERGE "GRAPHIC",360,ALL
360 PRINT CHR$(26):PRINT
363 PRINT TAB(18);"LEVEL MENU
366 FOR I=1 TO 4:PRINT:NEXT
370 PRINT "      First, ";USER$;", you must pick the level of "
380 PRINT "      hardness you desire from the five"
390 PRINT "      choices available. Or, you may EXIT back"
400 PRINT "      to the original math program."
410 PRINT
420 PRINT "        1 > LEVEL 1. (Single whole numbers)"
430 PRINT "        2 > LEVEL 2, (Complex whole numbers)"
440 PRINT "        3 > LEVEL 3, (Complex decimal numbers)"
450 PRINT "        4 > LEVEL 4, (Simple fractions)"
460 PRINT "        5 > LEVEL 5, (Complex fractions)"
510 PRINT "        E > EXIT, to KIDMATH"
520 PRINT:PRINT "            TYPE in your CHOICE?";
522 H$=INPUT$(1)
523 IF H$="E" OR H$="e" THEN PRINT:PRINT:PRINT "        WAIT!! Returning to KIDMATH":CHAIN "KM",970,ALL
524 H=VAL(H$)
530 PRINT CHR$(26)
540 IF H<=0 OR H>=6 THEN PRINT CHR$(7):FOR I=1 TO 6:PRINT:NEXT I:PRINT "    The number must be between 1 and 5, or E":FOR I=1 TO 1500:NEXT I:GOTO 360
550 PRINT CHR$(26):PRINT:PRINT:PRINT:PRINT:PRINT "Now, ";USER$;", you must pick whether you want REGULAR"
560 PRINT "DRILL or TEST for a possible REWARD."
570 PRINT:PRINT:PRINT:PRINT "         A >  REGULAR DRILL"
580 PRINT "         B >  TEST and/or REWARD (20 problems)
590 PRINT:PRINT:PRINT"          TYPE in your CHOICE?";
592 KK$=INPUT$(1)
600 IF KK$<>"A" AND KK$<>"a" AND KK$<>"B" AND KK$<>"b" THEN PRINT CHR$(26)CHR$(7):PRINT "   Your CHOICE must be either 'A' or 'B' ONLY.":FOR I=1 TO 1500:NEXT:GOTO 550
605 IF KK$="a" THEN KK$="A" ELSE IF KK$="b" THEN KK$="B"
610 PRINT CHR$(26)
620 ON H GOTO 1000,2000,3000,4000,5000
1000 REM "LEVEL 1"
1010 GOSUB 20000
1020 GOSUB 30000
1030 GOSUB 40000
1040 A=INT(RND(A)*10)
1050 B=INT(RND(B)*10)
1060 C=A+B
1070 IF A=0 OR B=0 THEN 1020
1080 PRINT CHR$(26)
1090 PRINT "PROBLEM NUMBER ";S;".":PRINT:PRINT
1100 PRINT "        ";
1110 PRINT USING N$;C
1120 PRINT "      - ";
1130 PRINT USING N$;A;
1140 PRINT "          ";C;"-";A;"="
1150 PRINT "       ____"
1160 GOSUB 50000
1170 PRINT:IF T=B AND KK$="A" THEN GOSUB 62400:PRINT:PRINT USER$;" Your ANSWER ";B;" is CORRECT!!!":WWW=0:R=R+1 ELSE IF T=B AND KK$="B" THEN GOSUB 63000:PRINT:PRINT USER$;" Your ANSWER ";B;" is CORRECT!!!":GOTO 1200
1180 GOSUB 50010
1190 IF T<>B AND WWW=0 THEN GOSUB 62100:W=W+1:WWW=WWW+1:PRINT:PRINT "SORRY!! WRONG answer, Try again.":GOTO 1090 ELSE IF T<>B AND WWW=1 THEN GOSUB 62200:W=W+1:WWW=WWW+1:PRINT:PRINT "SORRY!! WRONG answer. Try again.":GOTO 1090
1200 IF KK$="B" AND R=20 THEN 1220 ELSE GOSUB 60000
1210 IF X$<>"S" THEN S=S+1:GOTO 1020 ELSE PRINT CHR$(26)CHR$(7):GOTO 1200
1220 PRINT "  You had ";R;" RIGHT ANSWERS and ";W;" WRONG ANSWERS."
1225 IF KK$="A" THEN PRINT"        Press <RETURN> to CONTINUE"
1230 PRINT " Press L for new LEVEL, A for new AREA,  Q to QUIT";
1235 X$=INPUT$(1):IF X$=CHR$(13) THEN 610 ELSE IF X$="L" OR X$="l" THEN 360 ELSE IF X$="Q" OR X$="q" THEN SYSTEM ELSE SEED=SEED+1:COMMON SEED:CHAIN "KM",970,ALL
1290 END
2000 REM "LEVEL 2"
2010 GOSUB 20000
2020 GOSUB 30000
2030 GOSUB 40000
2040 A=INT(RND(A)*1000)
2050 B=INT(RND(B)*1000)
2060 C=A+B
2070 PRINT CHR$(26)
2080 PRINT "PROBLEM NUMBER ";S;".":PRINT:PRINT
2090 PRINT "  ";
2100 PRINT USING O$;C
2110 PRINT " -";
2120 PRINT USING O$;A;
2130 PRINT "          ";
2140 PRINT USING O$;C;
2150 PRINT " -";
2160 PRINT USING O$;A;
2170 PRINT " ="
2180 PRINT " _____
2190 GOSUB 50000
2200 PRINT:IF T=B AND KK$="A" THEN GOSUB 62400:PRINT:PRINT USER$;" Your ANSWER ";B;" is CORRECT!!!":WWW=0:R=R+1 ELSE IF T=B AND KK$="B" THEN GOSUB 63000:PRINT:PRINT USER$;" Your ANSWER ";B;" is CORRECT!!!":GOTO 2230
2210 GOSUB 50010
2220 IF T<>B AND WWW=0 THEN GOSUB 62100:W=W+1:WWW=WWW+1:PRINT:PRINT "SORRY!! WRONG answer. Try again.":GOTO 2080 ELSE IF WWW=1 THEN GOSUB 62200:W=W+1:WWW=WWW+1:PRINT:PRINT "SORRY!! WRONG answer. Try again.":GOTO 2080
2230 IF KK$="B" AND R=20 THEN 1220 ELSE GOSUB 60000
2240 IF X$<>"S" THEN S=S+1:GOTO 2020 ELSE PRINT CHR$(26)CHR$(7):GOTO 2230
3000 REM "LEVEL 3"
3010 GOSUB 20000
3020 GOSUB 30000
3030 GOSUB 40000
3040 A=INT(RND(A)*100)/10
3050 B=INT(RND(B)*100)/10
3060 IF A=0 OR B=0 THEN 3020
3070 A=A*85.3
3080 B=B*26.2
3090 A=INT(A*100)/100
3100 B=INT(B*100)/100
3110 IF B>=A THEN 3020
3120 C=A+B
3130 PRINT CHR$(26)
3140 PRINT "PROBLEM NUMBER ";S;".":PRINT:PRINT
3150 PRINT "       ";
3160 PRINT USING P$;C
3170 PRINT "     - ";
3180 PRINT USING P$;A;
3190 PRINT "      ";C;" - ";A;" ="
3200 PRINT "      ________"
3210 PRINT:PRINT:INPUT "TYPE in your ANSWER, then PRESS RETURN/ENTER";T
3220 T=INT(T*100)/100
3230 IF T<=B+.009 AND T>=B+.009 THEN T=B
3240 PRINT:IF T=B AND KK$="A" THEN GOSUB 62400:PRINT:PRINT USER$;" Your ANSWER ";B;" is CORRECT !!!":WWW=0:R=R+1 ELSE IF T=B AND KK$="B" THEN GOSUB 63000:PRINT:PRINT USER$;" Your ANSWER ";B;" is CORRECT!!!":GOTO 3270
3250 GOSUB 50010
3260 IF T<>B AND WWW=0 THEN GOSUB 62100:W=W+1:WWW=WWW+1:PRINT:PRINT "SORRY!! WRONG answer, Try again.":GOTO 3140 ELSE IF T<>B AND WWW=1 THEN GOSUB 62200:W=W+1:WWW=WWW+1:PRINT:PRINT "SORRY!! WRONG answer. Try again.":GOTO 3140
3270 IF KK$="B" AND R=20 THEN 1220 ELSE GOSUB 60000
3280 IF X$<>"S" THEN S=S+1:GOTO 3020 ELSE PRINT CHR$(26)CHR$(7):GOTO 3270
4000 REM "LEVEL 4"
4010 GOSUB 20000
4020 GOSUB 40000
4030 RESTORE:READ A,B,C,D
4040 A=INT(RND(A)*1000):B=INT(RND(B)*1000):C=INT(RND(C)*1000):D=INT(RND(D)*1000)
4050 IF A=0 OR B=0 OR C=0 OR D=0 THEN 4030
4060 FOR I=1 TO 5
4070 IF A>=10 THEN A=INT(A/10)
4080 IF B>=10 THEN B=INT(B/10)
4090 IF C>=10 THEN C=INT(C/10)
4100 IF D>=10 THEN D=INT(D/10)
4110 NEXT I
4120 IF A/B<C/D THEN SWAP A,C:SWAP B,D
4130 F=B*D
4140 E=(F/B)*A
4150 G=(F/D)*C
4160 H=E-G
4170 Y=H:Z=F
4180 J=9
4190 WHILE J>=1
4200 FOR K=1 TO 3
4210 IF H/J=INT(H/J) AND F/J=INT(F/J) THEN L=H/J:M=F/J:H=L:F=M
4220 NEXT K
4230 J=J-1
4240 WEND
4250 IF L/M=INT(L/M) THEN 4030
4260 O=INT(L/M)
4270 P=L-(O*M)
4280 PRINT CHR$(26)
4290 PRINT "PROBLEM NUMBER ";S;".":PRINT
4300 PRINT "    ";A;"   ";C
4310 PRINT "    ___ - ___  ="
4320 PRINT "    ";B;"   ";D
4330 PRINT:PRINT "Your ANSWER will be in THREE PARTS, each SEPARATED
4340 PRINT "by a COMMA ','. First ENTER the WHOLE NUMBER"
4350 PRINT "(0 if NONE), then the NUMERATOR and finally the
4360 PRINT "DENOMINATOR.                                15
4370 PRINT "(EXAMPLE: 3,15,16 would be entered for  3  ___ )"
4380 PRINT "                                            16"
4390 PRINT:PRINT "Be sure to REDUCE you  ANSWER to the LOWEST form"
4400 PRINT "POSSIBLE."
4410 PRINT:INPUT "Do this NOW! (Then press RETURN/ENTER)";T,U,V
4420 PRINT: IF T=O AND U=P AND V=M AND KK$="A" THEN GOSUB 62400:PRINT:PRINT "Your WHOLE NUMBER";T;"NUMERATOR";U;"and DENOMINATOR";V;CHR$(10)CHR$(13);"are all CORRECT ";USER$;" !!":R=R+1:WWW=0:GOTO 4490
4430 PRINT: IF T=O AND U=P AND V=M AND KK$="B" THEN GOSUB 63000:PRINT:PRINT "Your WHOLE NUMBER";T;"NUMERATOR";U;"and DENOMINATOR";V;CHR$(10)CHR$(13);"are all CORRECT ";USER$;" !!":GOTO 4800
4440 IF WWW=2 THEN GOSUB 62300:PRINT:PRINT "SORRY!! You missed the same problem 3 times. Look";CHR$(10)CHR$(13);"at the right answer.":PRINT:W=W+1:PRINT:GOTO 4490 
4450 IF T<>O OR U<>P OR V<>M THEN W=W+1:WWW=WWW+1
4460 IF WWW=1 THEN GOSUB 62100:PRINT:PRINT "SORRY!! WRONG answer. Try again." ELSE IF WWW=2 THEN GOSUB 62200:PRINT:PRINT "SORRY!! WRONG answer. Try again."
4470 IF T=0 AND U=Y AND V=Z AND Z<>M THEN PRINT "Your NUMERATOR";Y;"and DENOMINATOR";Z;"are CORRECT,";CHR$(10)CHR$(13);"but you DID NOT REDUCE far enough.":PRINT:GOTO 4290
4480 IF T=0 AND U=L AND V=M AND L>M THEN PRINT "Your NUMERATOR";L;"and DENOMINATOR";M;"are CORRECT,";CHR$(10)CHR$(13);"but you forgot to MAKE your ANSWER a WHOLE ";CHR$(10)CHR$(13);"NUMBER and FRACTION.":PRINT:GOTO 4290 ELSE GOTO 4290
4490 PRINT
4500 PRINT USING N$;A;
4510 PRINT "  ";
4520 PRINT USING N$;C;
4530 PRINT "    ";
4540 PRINT USING Q$;E;
4550 PRINT "  ";
4560 PRINT USING Q$;G;
4570 PRINT "    ";
4580 PRINT USING Q$;Y;
4590 PRINT "      ";
4600 PRINT USING Q$;L;
4610 PRINT "         ";
4620 PRINT USING Q$;P
4630 PRINT " _ - _ =   __ - __ =  ___  or  ___  or  ";
4640 PRINT USING Q$;O;
4650 PRINT " __"
4660 PRINT USING N$;B;
4670 PRINT "  ";
4680 PRINT USING N$;D;
4690 PRINT "    ";
4700 PRINT USING Q$;Z;
4710 PRINT "  ";
4720 PRINT USING Q$;Z;
4730 PRINT "    ";
4740 PRINT USING Q$;Z;
4750 PRINT "      ";
4760 PRINT USING Q$;M;
4770 PRINT "         ";
4780 PRINT USING Q$;M
4790 IF WWW=2 THEN PRINT:PRINT:GOTO 1220
4800 IF KK$="B" AND R=20 THEN 1220 ELSE GOSUB 60000
4810 IF X$<>"S" THEN S=S+1:GOTO 4020 ELSE PRINT CHR$(26)CHR$(7):GOTO 4800
5000 REM "LEVEL 5"
5010 GOSUB 20000
5020 GOSUB 40000
5030 RESTORE:READ A,B,C,D
5040 A=INT(RND(A)*1000):B=INT(RND(B)*1000):C=INT(RND(C)*1000):D=INT(RND(D)*1000)
5050 IF A=0 OR B=0 OR C=0 OR D=0 THEN 5030
5060 FOR I=1 TO 5
5070 IF A>=100 THEN A=INT(A/10)
5080 IF B>=100 THEN B=INT(B/10)
5090 IF C>=100 THEN C=INT(C/10)
5100 IF D>=100 THEN D=INT(D/10)
5110 NEXT I
5120 IF A/B<C/D THEN SWAP A,C:SWAP B,D
5130 F=B*D
5140 E=(F/B)*A
5150 G=(F/D)*C
5160 H=E-G
5170 Y=H:Z=F
5180 J=9
5190 WHILE J>=1
5200 FOR K=1 TO 4
5210 IF H/J=INT(H/J) AND F/J=INT(F/J) THEN L=H/J:M=F/J:H=L:F=M
5220 NEXT K
5230 J=J-1
5240 WEND
5250 IF L/M=INT(L/M) THEN 5030
5260 O=INT(L/M)
5270 P=L-(O*M)
5280 PRINT CHR$(26)
5290 PRINT "PROBLEM NUMBER ";S;".":PRINT
5300 PRINT "    ";A;"    ";C
5310 PRINT "    ___  -  ___ ="
5320 PRINT "    ";B;"    ";D
5330 PRINT:PRINT "Your ANSWER will be in THREE parts, each SEPARATED
5340 PRINT "by a COMMA ','. First ENTER the WHOLE NUMBER"
5350 PRINT "(0 if NONE), then the NUMERATOR and FINALLY the
5360 PRINT "DENOMINATOR.                                15
5370 PRINT "(EXAMPLE: 3,15,16 would be entered for  3  ___ )"
5380 PRINT "                                            16"
5390 PRINT:PRINT "Be sure to REDUCE your ANSWER to the LOWEST form"
5400 PRINT "POSSIBLE."
5410 PRINT:INPUT "Do this NOW! (Then press RETURN/ENTER)";T,U,V
5420 PRINT: IF T=O AND U=P AND V=M AND KK$="A" THEN GOSUB 62400:PRINT:PRINT "Your WHOLE NUMBER";T;"NUMERATOR";U;"and DENOMINATOR";V;CHR$(10)CHR$(13);"are all CORRECT ";USER$;" !!":R=R+1:WWW=0:GOTO 5490
5430 PRINT: IF T=O AND U=P AND V=M AND KK$="B" THEN GOSUB 63000:PRINT:PRINT "Your WHOLE NUMBER";T;"NUMERATOR";U;"and DENOMINATOR";V;CHR$(10)CHR$(13);"are all CORRECT ";USER$;" !!":GOTO 5800
5440 IF WWW=2 THEN GOSUB 62300:PRINT:PRINT "SORRY!! You missed the same problem 3 times. Look";CHR$(10)CHR$(13);"at the right answer.":PRINT:W=W+1:PRINT:GOTO 5490 
5450 IF T<>O OR U<>P OR V<>M THEN W=W+1:WWW=WWW+1
5460 IF WWW=1 THEN GOSUB 62100:PRINT:PRINT "SORRY!! WRONG answer. Try again." ELSE IF WWW=2 THEN GOSUB 62200:PRINT:PRINT "SORRY!! WRONG answer. Try again."
5470 IF T=0 AND U=Y AND V=Z AND Z<>M THEN PRINT "Your NUMERATOR";Y;"and DENOMINATOR";Z;"are CORRECT,";CHR$(10)CHR$(13);"but you DID NOT REDUCE far enough.":PRINT:GOTO 5290
5480 IF T=0 AND U=L AND V=M AND L>M THEN PRINT "Your NUMERATOR";L;"and DENOMINATOR";M;"are CORRECT,";CHR$(10)CHR$(13);"but you forgot to MAKE your ANSWER a WHOLE ";CHR$(10)CHR$(13);"NUMBER and FRACTION.":PRINT:GOTO 5290 ELSE GOTO 5290
5490 PRINT
5500 PRINT USING N$;A;
5510 PRINT "   ";
5520 PRINT USING N$;C;
5530 PRINT "    ";
5540 PRINT USING O$;E;
5550 PRINT "   ";
5560 PRINT USING O$;G;
5570 PRINT "    ";
5580 PRINT USING O$;Y;
5590 PRINT "    ";
5600 PRINT USING O$;L;
5610 PRINT "        ";
5620 PRINT USING O$;P
5630 PRINT "__ - __ =  ____ - ____ =  ____ or ____ or";
5640 PRINT USING O$;O;
5650 PRINT " ____"
5660 PRINT USING N$;B;
5670 PRINT "   ";
5680 PRINT USING N$;D;
5690 PRINT "    ";
5700 PRINT USING O$;Z;
5710 PRINT "   ";
5720 PRINT USING O$;Z;
5730 PRINT "    ";
5740 PRINT USING O$;Z;
5750 PRINT "    ";
5760 PRINT USING O$;M;
5770 PRINT "        ";
5780 PRINT USING O$;M
5790 IF WWW=2 THEN PRINT:PRINT:GOTO 1220
5800 IF KK$="B" AND R=20 THEN 1220 ELSE GOSUB 60000
5810 IF X$<>"S" THEN S=S+1:GOTO 5020 ELSE PRINT CHR$(26)CHR$(7):GOTO 5800
6000 GOTO 360
7000 GOTO 360
8000 GOTO 360
9000 GOTO 360
10000 REM "DATA & SUB-ROUTINES""
10010 DATA 1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,-999
20000 RANDOMIZE SEED
20040 R=0
20050 W=0
20060 WWW=0
20070 S=1
20080 RETURN
30000 RESTORE:READ A,B
30010 IF A=-999 OR B=-999 THEN PRINT CHR$(26):PRINT "OUT OF DATA FOR PROBLEM GENERATION":PRINT CHR$(26):GOTO 3080
30020 RETURN
40000 N$="##":O$="####":P$="####.##":Q$="###":RETURN
50000 PRINT:PRINT:INPUT "TYPE in your ANSWER, then press RETURN/ENTER";T:RETURN 
50010 IF WWW=2 THEN GOSUB 62300:PRINT:PRINT "SORRY!! You missed the same problem 3 times.";CHR$(10)CHR$(13);"Maybe you should START OVER or try a LOWER LEVEL.":W=W+1:PRINT:GOTO 1220 ELSE RETURN
60000 PRINT:PRINT "Press S for SCORE, ANY other key to CONTINUE?";
60005 X$=INPUT$(1)
60010 IF X$="S" OR X$="s" THEN PRINT CHR$(26):GOTO 1220 ELSE RETURN
 SCORE, ANY other key to CONTINUE?";
60005 X$=INPUT$(1)
60010 