A homework helper for coordinate geometry. You enter the x and y coordinates of two points and a question number. The program draws both points on a pair of axes and joins them, then shows the working for three results on separate screens: the distance, with a drawn square-root sign over each step; the slope as rise over run, or “Slope is undefined” for a vertical line; and the midpoint. Each screen waits for a key, and z copies it to the printer.
No author is named.
Program Analysis
Structure
- Lines 10–50:
DEF FNdefinitions for distance, slope, two-decimal rounding and the midpoint coordinates. - Lines 60–220: input, then the axes (origin at 127,100, five pixels per unit) and the line between the points. Pressing
sat the graph lets you enter new points. - Lines 230–340: the distance screen. Lines 360–410: slope. Lines 430–490: midpoint. The program then starts again with
RUN. - Lines 510–540: wait for a key and optionally
COPY.
The square-root sign
UDGs a–d are defined from DATA line 230: a root sign, a small “2” for squaring, a bar and a delta. The bar over each line of working is printed character by character with OVER 1, its length worked out from the LEN STR$ of the numbers in that line.
Notable Techniques
- The DATA in line 230 uses a variable
ufor repeated byte values: eachureads back the value just read. FN frounds to two decimals for display while the full values are kept for the arithmetic.
Potential Issues
FN d,FN m,FN pandFN qare defined but never used. The calculations are written out in full instead.- Points more than about 25 units from the origin are drawn off the axes, and a
DRAWpast the screen edge will stop the program.
This program came from an Oliger (JLO SAFE) disk, a copy of the SNUG library disk 13/14, and was converted to load from tape. No changes were needed. It was tested in ZEsarUX with the points (2,3) and (−4,5).
Source Code
10 DEF FN d(x,y,a,b)=SQR (((ABS (x-a))^2)+((ABS (y-b))^2))
20 DEF FN m(x,y,a,b)=(y-b)/(x-a)
30 DEF FN F(g)=INT (g*100)/100
40 DEF FN p(x,a)=(x+a)/2
50 DEF FN q(y,b)=(y+b)/2
60 CLS
70 INPUT "Enter X coordinate of Point A :";x
80 INPUT "Enter Y coordinate of Point A :";y
90 INPUT "Enter X coordinate of Point B :";a
100 INPUT "Enter Y coordinate of Point B :";b
110 INPUT "Enter Question# "; LINE a$
120 PRINT AT 0,0''AT 0,0; INVERSE 1;a$;: PRINT " (";x;",";y;") (";a;",";b;")"
130 PLOT 127,40: DRAW 0,120: PLOT 0,100: DRAW 254,0
140 LET xaxis=127: LET yaxis=100
150 GO SUB 200
160 PLOT xaxis+5*x,yaxis+5*y
170 DRAW -(xaxis+5*x)+(xaxis+5*a),-(yaxis+5*y)+(yaxis+5*b)
180 GO SUB 510: IF INKEY$="s" THEN GO TO 70
190 GO TO 240
200 FOR z=-60 TO 60 STEP 5: PLOT 126,z+yaxis: DRAW 2,0: NEXT z
210 FOR z=-125 TO 127 STEP 5: PLOT z+xaxis,99: DRAW 0,2: NEXT z
220 RETURN
230 DATA 7,4,u,136,72,40,16,0,u,24,36,8,16,60,0,u,255,0,u,u,u,u,u,u,u,8,20,u,34,u,127,0
240 RESTORE 230: FOR z=0 TO 31: READ u: POKE USR "a"+z,u: NEXT z
250 CLS : PRINT "Distance="'"accccccccccccccccc";AT 1,1; OVER 1;"(x1-x2)b+(y1-y2)b"
260 PRINT '"a(";FN f(x);"-";FN f(a);")b+(";FN f(y);"-";FN f(b);")b"
270 FOR z=1 TO (9+LEN (STR$ FN f(x))+LEN (STR$ (FN f(a)))+LEN (STR$ (FN f(y)))+LEN (STR$ (FN f(b)))): PRINT AT 3,z; OVER 1;"c": NEXT z
280 PRINT '"a(";FN f(x)-FN f(a);")b+(";FN f(y)-FN f(b);")b"
290 FOR z=1 TO (9+LEN (STR$ (FN f(x)-FN f(a)))+LEN (STR$ (FN f(y)-FN f(b)))): PRINT AT 5,z; OVER 1;"c": NEXT z
300 LET x1=(ABS (x-a))^2: LET y1=(ABS (y-b))^2
310 PRINT '"a";FN f(x1);"+";FN f(y1)
320 FOR z=1 TO (1+LEN (STR$ (FN f(x1)))+LEN (STR$ (FN f(y1)))): PRINT AT 7,z; OVER 1;"c": NEXT z
330 LET x1=x1+y1: PRINT '"a";FN f(x1): FOR z=1 TO LEN (STR$ (FN f(x1))): PRINT AT 9,z; OVER 1;"c": NEXT z
340 PRINT 'SQR x1
350 GO SUB 510: CLS
360 PRINT "Slope (m)="''"dy/dx"
370 PRINT '"(";FN f(y);"-";FN f(b);")/(";FN f(x);"-";FN f(a);")"
380 LET x1=x-a: LET y1=y-b
390 PRINT 'FN f(y1);"/";FN f(x1)
400 IF x1=0 THEN PRINT '"Slope is undefined.": GO TO 420
410 PRINT 'y1/x1
420 GO SUB 510: CLS
430 PRINT "Midpoint="''"OF X:";TAB 15;"OF Y:"'"(x1+x2)/2";TAB 15;"(y1+y2)/2"
440 PRINT '"(";FN f(x);"+";FN f(a);")/2";TAB 15;"(";FN f(y);"+";FN f(b);")/2"
450 LET x1=x+a: LET y1=y+b
460 PRINT 'FN f(x1);"/2";TAB 15;FN f(y1);"/2"
470 LET x1=x1/2: LET y1=y1/2
480 PRINT 'x1;TAB 15;y1
490 PRINT ''''TAB 10;"{";FN f(x1);",";FN f(y1);"}"
500 GO SUB 510: RUN
510 IF INKEY$<>"" THEN GO TO 510
520 PAUSE 0
530 IF INKEY$="z" THEN COPY
540 RETURNNote: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.


