Math Tutor is a simple arithmetic drill for children. After an introduction screen, you choose to add, subtract, multiply or divide, enter your first name, and pick how many digits the numbers should have (1 to 4). The program then sets random problems, written in column form, and addresses you by name when it asks for the answer. A correct answer brings the message “GOOD TRY AGAIN” and a new problem. After three wrong tries it shows the right answer.
A REM line credits it to BUTCH, © 1985: Butch Weinberg, whose Larken disks it came from.
Program Analysis
Structure
The menu choice Q is used directly in GO TO Q*100, so each operation has its own section at lines 100, 200, 300 and 400. The four sections are near copies of one another. The upper limit for the numbers comes from VAL A$( TO A), where A$="99999999", so choosing 2 digits gives problems up to 99. For subtraction and division the program draws new numbers until the second is no larger than the first. For multiplication and division the second number is a single digit, 1 to 9. The counter T tracks tries, and the subroutine at line 500 prints the answer after the third miss.
Notable Techniques
GO TO Q*100as a computed jump to the chosen section.- Digit count turned into a range by slicing a string of nines.
Potential Issues
- After the third wrong answer in the addition section, line 185 jumps to line 215 in the subtraction section, so the drill switches to subtraction. Testing confirmed this.
- Addition and multiplication stop on an answer of 0, but subtraction and division use 9999.
- Division uses
N/NNwithout forcing a whole result, so most answers are fractions that are hard to type exactly. - Line 41 (
C$<>"C" OR C$<>"Q") is always true. This is harmless here, because the valid answers are handled first. - The menu spells “DEVIDE”.
This copy came from a Larken disk. For tape, the LKDOS prefixes were removed from the SAVE and LOGICALL lines, and the saved variables were dropped. The opening REM was shortened. It was tested in ZEsarUX on a stock TS2068.
Source Code
10 REM special math program by BUTCH * 1985
11 FOR I=1 TO 3
12 PRINT
13 NEXT I
14 LET T=0
15 PRINT "IN THIS PROGRAM YOU WILL FIRST"
17 PRINT
20 PRINT "BE ASKED A SERIES OF QUESTIONS."
22 PRINT
25 PRINT "THEY WILL TELL THE COMPUTER "
27 PRINT
30 PRINT "WHAT YOU WOULD LIKE TO DO."
32 PRINT
34 PRINT "TO CONTINUE PRESS (C) / RETURN"
35 PRINT
36 PRINT "TO QUIT PRESS (Q)/ RETURN"
37 INPUT C$
38 IF C$="C" THEN GO TO 42
40 IF C$="Q" THEN STOP
41 IF C$<>"C" OR C$<>"Q" THEN GO TO 10
42 PRINT
43 PRINT
44 PRINT
45 PRINT "WOULD YOU LIKE TO "
46 PRINT
47 PRINT "(1) ADD"
49 PRINT
50 PRINT "(2) SUBTRACT"
51 PRINT
53 PRINT "(3) MULTIPLY"
55 PRINT
57 PRINT "(4) DEVIDE"
59 PRINT
60 PRINT "PRESS THE NUMBER OF THE ONE YOU"
63 PRINT
65 PRINT "WANT THEN RETURN"
70 INPUT Q
72 FOR I=1 TO 3
75 PRINT
77 NEXT I
80 GO TO Q*100
100 PRINT "WHAT IS YOUR FIRST NAME ?"
110 INPUT N$
113 PRINT
115 PRINT "OK ";N$;" HOW MANY # ACROSS?"
116 LET T=0
120 INPUT A
125 IF a<1 OR a>4 THEN GO TO 113
135 LET A$="99999999"
140 LET L=VAL A$( TO A)
145 LET N=INT (L*RND)+1
147 LET NN=INT (L*RND)+1
150 LET NNN=N+NN
153 PRINT
155 PRINT TAB 3;N
160 PRINT TAB 2;"+";NN
163 PRINT
165 PRINT "WHAT IS YOUR ANSWER? ";N$
166 PRINT
167 PRINT "ANSWER WITH 0 TO STOP"
170 INPUT AA
172 LET T=T+1
175 IF AA=0 THEN GO TO 10
177 PRINT
180 IF AA=NNN THEN PRINT "GOOD TRY AGAIN"
181 IF AA=NNN THEN GO TO 115
182 IF AA<>NNN AND T=3 THEN GO SUB 500
183 IF AA<>NNN AND T<>3 THEN GO TO 165
185 GO TO 215
200 PRINT "WHAT IS YOUR FIRST NAME ?"
210 INPUT N$
213 PRINT
215 PRINT "OK ";N$;" HOW MANY # ACROSS?"
216 LET T=0
220 INPUT A
225 IF a<1 OR a>4 THEN GO TO 213
235 LET A$="99999999"
240 LET L=VAL A$( TO A)
245 LET N=INT (L*RND)+1
247 LET NN=INT (L*RND)+1
248 IF NN>N THEN GO TO 247
250 LET NNN=N-NN
253 PRINT
255 PRINT TAB 3;N
260 PRINT TAB 2;"-";NN
263 PRINT
265 PRINT "WHAT IS YOUR ANSWER? ";N$
266 PRINT
267 PRINT "ANSWER WITH 9999 TO STOP"
270 INPUT AA
272 LET T=T+1
275 IF AA=9999 THEN GO TO 10
277 PRINT
280 IF AA=NNN THEN PRINT "GOOD TRY AGAIN"
281 IF AA=NNN THEN GO TO 215
282 IF AA<>NNN AND T=3 THEN GO SUB 500
283 IF AA<>NNN AND T<>3 THEN GO TO 265
285 GO TO 215
300 PRINT "WHAT IS YOUR FIRST NAME ?"
310 INPUT N$
313 PRINT
315 PRINT "OK ";N$;" HOW MANY # ACROSS?"
316 LET T=0
320 INPUT A
325 IF a<1 OR a>4 THEN GO TO 313
335 LET A$="99999999"
340 LET L=VAL A$( TO A)
345 LET N=INT (L*RND)+1
347 LET NN=INT (9*RND)+1
348 IF NN>N THEN GO TO 347
350 LET NNN=N*NN
353 PRINT
355 PRINT TAB 3;N
360 PRINT TAB 2;"*";NN
363 PRINT
365 PRINT "WHAT IS YOUR ANSWER? ";N$
366 PRINT
367 PRINT "ANSWER WITH 0 TO STOP"
370 INPUT AA
372 LET T=T+1
375 IF AA=0 THEN GO TO 10
377 PRINT
380 IF AA=NNN THEN PRINT "GOOD TRY AGAIN"
381 IF AA=NNN THEN GO TO 315
382 IF AA<>NNN AND T=3 THEN GO SUB 500
383 IF AA<>NNN AND T<>3 THEN GO TO 365
385 GO TO 315
400 PRINT "WHAT IS YOUR FIRST NAME ?"
410 INPUT N$
413 PRINT
415 PRINT "OK ";N$;" HOW MANY # ACROSS?"
416 LET T=0
420 INPUT A
425 IF a<1 OR a>4 THEN GO TO 413
435 LET A$="99999999"
440 LET L=VAL A$( TO A)
445 LET N=INT (L*RND)+1
447 LET NN=INT (9*RND)+1
448 IF NN>N THEN GO TO 447
450 LET NNN=N/NN
453 PRINT
455 PRINT TAB 3;N
460 PRINT TAB 2;"/";NN
463 PRINT
465 PRINT "WHAT IS YOUR ANSWER? ";N$
466 PRINT
467 PRINT "ANSWER WITH 9999 TO STOP"
470 INPUT AA
472 LET T=T+1
475 IF AA=9999 THEN GO TO 10
477 PRINT
480 IF AA=NNN THEN PRINT "GOOD TRY AGAIN"
481 IF AA=NNN THEN GO TO 415
482 IF AA<>NNN AND T=3 THEN GO SUB 500
483 IF AA<>NNN AND T<>3 THEN GO TO 465
485 GO TO 415
500 PRINT
510 PRINT
520 PRINT "SORRY YOU HAVE HAD 3 TRY'S"
530 PRINT "THE ANSWER WAS ";NNN
550 RETURN
9992 SAVE "Mathte.B1" LINE 1
9996 REM was LKDOS-onlyNote: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.


