5 REM This program is MATH
10 CLS:KEY OFF:CLEAR 100:GOSUB 100:GOSUB 1000
20 GOSUB 2000:RUN "menu"
50 RUN "menu"
100 GOSUB 59980
110 DEFSTR N:DIM NUMBER(15)
115 DB$=CHR$(31)+CHR$(29):D$=CHR$(31):B2$=STRING$(2,29):B3$=B2$+CHR$(29)
120 NUMBER(1)=" ??"+DB$+"?"+DB$+"?"+D$+B2$+"???"
130 NUMBER(2)="?????"+D$+B2$+"??"+D$+B2$+B2$+"??"+D$+B3$+"?????"
140 NUMBER(3)="?????"+DB$+B2$+"???"+DB$+"?"+DB$+B2$+B2$+"?????"
150 NUMBER(4)="  ??"+DB$+B3$+"?????"+D$+B2$+"?"+DB$+"?"
160 NUMBER(5)="?????"+DB$+B2$+B2$+"????"+D$+"?"+DB$+B2$+B2$+"????"
170 NUMBER(6)=" ??"+DB$+B2$+"????"+D$+B2$+B2$+"?"+D$+"???"+CHR$(30)+"?"+D$
180 NUMBER(7)="?????"+D$+B2$+"??"+DB$+B2$+"??"+D$+B2$+"?"
190 NUMBER(8)="?????"+DB$+B2$+B2$+"?????"+DB$+B2$+B2$+"?"+D$+"???"+CHR$(30)+"?"+D$
200 NUMBER(9)="?????"+DB$+B2$+B2$+"?????"+D$+B2$+"??"+DB$+B2$+"?"
210 NUMBER(10)="?????"+DB$+B2$+B2$+"?   ?"+DB$+B2$+B2$+"?   ?"+D$+B2$+B2$+"???"
220 NUMBER(11)=D$+" ???"+D$+B2$+"?"
230 NUMBER(12)=D$+" ???"
240 NUMBER(13)=D$+"???"+DB$+B2$+"? ?"
250 NUMBER(14)="  ?"+D$+B2$+"???"+D$+B2$+"?"
260 NUMBER(15)=" ???"+D$+D$+B3$+"???"
270 NUMBER(0)="     "+DB$+B2$+B2$+"     "+DB$+B2$+B2$+"     "+DB$+B2$+B2$+"     "
300 C$(1)="RIGHT":C$(2)="CORRECT":C$(3)="ABSOLUTELY":C$(4)="GOOD GOING":C$(5)="YOU'RE DOING OK!":C$(6)="I KNEW YOU'D GET THAT ONE"
990 RETURN
995 CLS:FOR I=1 TO 20:LOCATE I,67:PRINT"THIS IS A TEST";:NEXT I:END
1000 KEY OFF:COLOR 0,7:LOCATE 1,34:PRINT " Math Program "
1010 COLOR 7,0:LOCATE 3,1:PRINT "This program will drill you on simple math problems.  You may select the"
1020 PRINT "type(s) of problems which will be presented.  The operations available include:"
1030 LOCATE 6,10:COLOR 15:PRINT "1";:COLOR 7:PRINT" - Addition"
1040 LOCATE 7,10:COLOR 15:PRINT "2";:COLOR 7:PRINT" - Subtraction"
1050 LOCATE 8,10:COLOR 15:PRINT "3";:COLOR 7:PRINT" - Multiplication"
1060 LOCATE 9,10:COLOR 15:PRINT "4";:COLOR 7:PRINT" - Division"
1070 LOCATE 10,10:COLOR 15:PRINT "5";:COLOR 7:PRINT" - Addition and Subtraction
1080 LOCATE 11,10:COLOR 15:PRINT "6";:COLOR 7:PRINT" - Multiplication and Division"
1090 LOCATE 12,10:COLOR 15:PRINT "7";:COLOR 7:PRINT" - Addition, Subtraction, Multiplication and Division"
1100 LOCATE 14,1:PRINT "Enter the number for the type(s) of operations desired - ";
1110 GOSUB 59990
1120 IF INSTR("1234567",IKEY$)=0 THEN 1110
1130 L1=VAL(IKEY$):LOCATE 14,1:PRINT STRING$(75,32)
1140 LOCATE 14,1:PRINT"Enter the level of difficulty desired ";:COLOR 15:PRINT"(1-10)";:COLOR 7:PRINT" - ";
1150 INPUT L:IF L<1 OR L>10 THEN 1140
1160 RETURN
2000 GOSUB 3000 'initialize result tally
2010 ON L1 GOSUB 4000,5000,6000,7000,8000,9000,10000 'select value
2020 GOSUB 11000 'display the problem
2030 GOSUB 12000 'accept the answer
2040 GOSUB 13000 'evaluate answer & tally results
2050 IF R=1 THEN 2010
2060 GOSUB 13900 'give final results
2070 TIMEOUT=12:GOSUB 59950:RETURN
3000 FOR I=1 TO 4
3010 S(1,I)=0 'number of consecutive correct responses
3020 IF L1=I OR L1=7 OR (L1=5 AND I<3) OR (L1=6 AND I>2) THEN S(2,I)=L ELSE S(2,I)=0 'level of difficulty
3030 S(3,I)=0 'total correct answers
3040 NEXT I
3050 S=0 'total exercises tried
3060 RETURN
4000 REM select addition values
4010 V1=INT(RND*10*S(2,1)):V2=INT(RND*(10*S(2,1)-V1)):T=1:RETURN
5000 REM select subtraction values
5010 V1=INT(RND*10*S(2,2)):V2=INT(RND*V1):T=2:RETURN
6000 REM select multiplication values
6010 V1=INT(RND*5*S(2,3)):IF V1=0 THEN 6010 ELSE V2=INT((RND*10*S(2,3))/V1):T=3:RETURN
7000 REM select division values
7010 V1=INT(RND*10*S(2,4)):V2=INT(RND*V1):IF V1=0 OR V2=0 THEN 7010 ELSE IF INT(V1/V2)<>V1/V2 THEN 7010
7020 T=4:RETURN
8000 REM select addition or subtraction values
8010 IF RND<.5 THEN 4000 ELSE 5000
9000 REM select multiplication or division values
9010 IF RND<.5 THEN 6000 ELSE 7000
10000 REM select addition, subtraction, multiplication or division values
10010 ON INT(RND*10)+1 GOTO 4000,5000,6000,7000,4000,5000,6000,7000,4000,5000:STOP
11000 REM display the problem
11010 CLS
11020 V1$=STR$(V1):V2$=STR$(V2)
11025 IF V1=0 THEN LOCATE 11,16:PRINT NUMBER(10);:GOTO 11050
11030 IF LEN(V1$)>2 THEN LOCATE 11,10:PRINT NUMBER(VAL(MID$(V1$,2,1)));
11035 IF VAL(RIGHT$(V1$,1))=0 THEN LOCATE 11,16:PRINT NUMBER(10);:GOTO 11050
11040 LOCATE 11,16:PRINT NUMBER(VAL(RIGHT$(V1$,1)));
11050 LOCATE 11,27:PRINT NUMBER(T+10);
11060 IF V2=0 THEN LOCATE 11,41:PRINT NUMBER(10);:GOTO 11100
11070 IF LEN(V2$)>2 THEN LOCATE 11,35:PRINT NUMBER(VAL(MID$(V2$,2,1)));
11080 IF VAL(RIGHT$(V2$,1))=0 THEN LOCATE 11,41:PRINT NUMBER(10);:GOTO 11100
11090 LOCATE 11,41:PRINT NUMBER(VAL(RIGHT$(V2$,1)));
11100 LOCATE 11,53:PRINT NUMBER(15);
11110 RETURN
12000 REM accept the answer
12010 LOCATE 18,31,,0,13:COLOR 15:PRINT"The answer is - ";:INPUT A$:COLOR 7
12020 A=VAL(A$):LOCATE ,,,13
12030 IF A=0 THEN LOCATE 11,71:NUMBER=NUMBER(10):GOSUB 12500:GOTO 12070
12040 IF LEN(A$)>1 THEN LOCATE 11,65:NUMBER=NUMBER(VAL(LEFT$(A$,1))):GOSUB 12500
12050 IF VAL(RIGHT$(A$,1))=0 THEN LOCATE 11,71:NUMBER=NUMBER(10):GOSUB 12500:GOTO 12070
12060 LOCATE 11,71:NUMBER=NUMBER(VAL(RIGHT$(A$,1))):GOSUB 12500
12070 RETURN
12500 FOR I=1 TO LEN(NUMBER):PRINT MID$(NUMBER,I,1);:NEXT I:RETURN
13000 REM evaluate the answer & tally the results
13010 C%=0:ON T GOSUB 13100,13200,13300,13400
13020 IF C%=1 THEN GOSUB 13500 ELSE GOSUB 13700
13030 LOCATE 25,27:PRINT"Another exercise (";:COLOR 15:PRINT"Y";:COLOR 7:PRINT" or ";:COLOR 15:PRINT"N";:COLOR 7:PRINT")?" ;
13040 GOSUB 59990:IF INSTR("ynsYNS",IKEY$)=0 THEN 13040
13050 IF IKEY$="y" OR IKEY$="Y" THEN R=1
13060 IF IKEY$="n" OR IKEY$="N" THEN R=0
13070 IF IKEY$="s" OR IKEY$="S" THEN GOSUB 13900:GOTO 13030
13080 RETURN
13100 V3=V1+V2:IF A=V3 THEN C%=1
13110 RETURN
13200 V3=V1-V2:IF A=V3 THEN C%=1
13210 RETURN
13300 V3=V1*V2:IF A=V3 THEN C%=1
13310 RETURN
13400 V3=V1/V2:IF A=V3 THEN C%=1
13410 RETURN
13500 PLAY "mbc16c16c16ge8g"
13510 S(1,T)=S(1,T)+1:S(3,T)=S(3,T)+1
13520 IF S(1,T)>15 THEN S(1,T)=0:S(2,T)=S(2,T)+1
13530 IF S(2,T)>10 THEN S(2,T)=10
13540 FOR I=15 TO 25:LOCATE I,1:PRINT SPACE$(79);:NEXT I
13550 S=S+1:IX=INT(RND*6)+1
13560 LOCATE 20,40-LEN(C$(IX))/2:COLOR 15:PRINT C$(IX):COLOR 7
13570 RETURN
13700 PLAY "n50n25":S(1,T)=0:S=S+1
13705 NUMBER=NUMBER(0):LOCATE 11,65:GOSUB 12500:LOCATE 11,71:GOSUB 12500
13710 IF V3=0 THEN LOCATE 11,65:NUMBER=NUMBER(0):GOSUB 12500:LOCATE 11,71:NUMBER=NUMBER(10):GOSUB 12500:GOTO 13800
13720 IF V3>9 THEN LOCATE 11,65:NUMBER=NUMBER(VAL(MID$(STR$(V3),2,1))):GOSUB 12500
13730 IF INT(V3/10)=V3/10 THEN LOCATE 11,71:NUMBER=NUMBER(10):GOSUB 12500:GOTO 13800
13740 LOCATE 11,71:NUMBER=NUMBER(VAL(RIGHT$(STR$(V3),1))):GOSUB 12500
13800 LOCATE 18,28:COLOR 15:PRINT"NOTE THE CORRECT ANSWER":COLOR 7
13810 RETURN
13900 CLS:LOCATE 12,30:PRINT"CONSECUTIVE      DIFFICULTY     TOTAL"
13910 LOCATE 13,32:PRINT"CORRECT          LEVEL       CORRECT"
13920 LOCATE 14,20:PRINT STRING$(50,"?")
13930 LOCATE 15,1:PRINT"ADDITION" TAB(20) USING"?             ##               ##          ##    ?";S(1,1),S(2,1),S(3,1)
13940 LOCATE 16,1:PRINT"SUBTRACTION" TAB(20) USING"?             ##               ##          ##    ?";S(1,2),S(2,2),S(3,2)
13950 LOCATE 17,1:PRINT"MULTIPLICATION" TAB(20) USING"?             ##               ##          ##    ?";S(1,3),S(2,3),S(3,3)
13960 LOCATE 18,1:PRINT"DIVISION" TAB(20) USING"?             ##               ##          ##    ?";S(1,4),S(2,4),S(3,4)
13965 LOCATE 19,20:PRINT STRING$(50,"?")
13970 LOCATE 22,30:PRINT USING"Percent Correct = ###";INT(((S(3,1)+S(3,2)+S(3,3)+S(3,4))/S)*100)
13980 RETURN
59950 TIMEOUT$=TIME$:TIME2=VAL(LEFT$(TIMEOUT$,2))*120+VAL(MID$(TIMEOUT$,4,2))*60+VAL(RIGHT$(TIMEOUT$,2))
59960 TIMEOUT$=TIME$:TIME3=VAL(LEFT$(TIMEOUT$,2))*120+VAL(MID$(TIMEOUT$,4,2))*60+VAL(RIGHT$(TIMEOUT$,2))
59970 IF TIMEOUT > TIME3 - TIME2 THEN 59960 ELSE RETURN
59980 RNDTIME$=TIME$:RNDVAL=VAL(LEFT$(RNDTIME$,2))*120+VAL(MID$(RNDTIME$,4,2))*60+VAL(RIGHT$(RNDTIME$,2)):RANDOMIZE RNDVAL:RETURN
59990 IKEY$=INKEY$:IF IKEY$="" THEN 59990 ELSE RETURN