10 PRINT "COORDINATE PLOT"
20 PRINT
28 REM - DIMENSION OF X() AND Y() SHOULD BE LIMITED TO (N+1);
29 REM - WHERE N=THE NUMBER OF POINTS BEING PLOTTED, MAX. LIMIT 99
30 DIM X(100),Y(100)
39 REM - INPUT INFORMATION TO SET UP AXES
40 PRINT  "X-AXIS:  LEFT ENDPOINT, RIGHT ENDPOINT, INCREMENT";
50 INPUT A1, A2, A3
60 PRINT  "Y-AXIS: LOWER ENDPOINT, UPPER ENDPOINT, INCERMENT";
70 INPUT B1, B2, B3
80 B2=(B2-B1)/B3
88 REM - Y-AXIS TOO LONG FOR OUTPUT DEVICE? IF YES, CHANGE ENDPOINTS 
89 REM - OR INCREASE INCREMENT
90 IF B2<=70 THEN 120
100 PRINT "Y-RANGE TOO LARGE"
110 GOTO 60
120 PRINT "NUMBER OF POINTS TO BE PLOTTED";
130 INPUT N
139 REM - NO POINTS TO PLOT? END PROGRAM
140 IF N=0 THEN 1070
149 REM - TOO MANY POINTS? IF YES, REENTER NUMBER OF POINTS
150 IF N<=99 THEN 180
160 PRINT "TOO MANY POINTS"
170 GOTO 120
179 REM - LOOP TO INPUT X,Y COORDINATES FOR EACH POINT
180 FOR I=1 TO N
190 IF I>1 THEN 220
200 PRINT "COORDINATES OF POINT ";I;
210 GOTO 230
220 PRINT "               POINT ";I;
230 INPUT X(I), Y(I)
239 REM - ROUND OFF EACH X,Y TO NEAREST INCREMENT ON AXIS
240 X(I)=INT((X(I)-A1)/A3+.5)
250 Y(I)=INT((Y(I)-B1)/B3+.5)
260 NEXT I
269 REM - CALCULATE ADDITIONAL X AND Y COORDINATE
270 Y(N+1)=INT(B2+.5)+1
280 X(N+1)=INT((A2-A1)/A3+.5)+1
290 PRINT
299 REM - NOTE WHERE AXES CROSS
300 PRINT "INTERSECTION OF AXES AT (";A1;",";B1;")"
310 PRINT
319 REM - SORT COORDINATES; REORDER X(1) TO X(n) SMALLEST TO LARGEST
320 FOR J=1 TO N
330 FOR I=1 TO N-J
340 A=X(I)
350 B=Y(I)
360 C=X(I+1)
370 D=Y(I+1)
380 IF A<C THEN 430
390 X(I)=C
400 Y(I)=D
410 X(I+1)=A
420 Y(I+1)=B
430 NEXT I
440 NEXT J
449 REM - NEXT POINT TO BE PLOTTED STORED IN T
450 T=1
459 REM - SKIP POINTS OUT OF X-POSITIVE RANGE
460 FOR P=0 TO N-1
470 IF X(P+1)>=0 THEN 490
480 NEXT P
489 REM - LOOP TO CALL UP EACH X-INCREMENT FOR LINES OF PRINT
490 FOR I=0 TO INT((A2-A1)/A3+.5)
500 T=T+P
509 REM - COUNT NUMBER OF POINTS TO BE PLOTTED ON EACH LINE IN P
510 P=0
519 REM - ALL POINTS PLOTTED?
520 IF T>N THEN 540
529 REM - X-VALUE ON X-LINE? IF YES, TEST FOR Y
530 IF X(T)=I THEN 590
539 REM - FIRST LINE? IF YES, Y-AXIS MUST BE PLOTTED
540 IF I=0 THEN 570
549 REM - PLOT X-AXIS
550 PRINT "*";
560 GOTO 1040
570 S=N+1
580 GOTO 920
590 FOR L=T TO N
599 REM - NEXT POINT PLOTTED ON SAME LINE?
600 IF X(L)>X(T) THEN 630
609 REM - COUNT POINTS TO BE PLOTTED ON EACH LINE
610 P=P+1
620 NEXT L
629 REM - PLOT ONE POINT
630 IF P=1 THEN 730
638 REM - LOOP TO SORT Y-COORDINATES WITH EQUAL X-COORDINATES;
639 REM - REORDER SMALLEST TO LARGEST
640 FOR J=1 TO P
650 FOR L=1 TO P-J
660 D=Y(T+L-1)
670 B=Y(T+L)
680 IF D<=B THEN 710
690 Y(T+L-1)=B
700 Y(T+L)=D
710 NEXT L
715 FOR J=1 TO P
720 NEXT J
730 FOR L=0 TO P-1
740 Z=Y(T+L)
749 REM - TEST FOR OUT-OF-RANGE Y-COORDINATE
750 IF Z>=0 THEN 770
760 NEXT L
769 REM - POINT TO BE PLOTTED ON X-AXIS?
770 IF I=0 THEN 910
779 REM - POINT TO BE PLOTTED ON Y-AXIS?
780 IF Z=0 THEN 800
789 REM - PLOT X-AXIS
790 PRINT "*";
800 IF L=P-1 THEN 870 
810 FOR J=L TO P-1
819 REM - TEST FOR OUT-OF-RANGE Y-COORDINATE
820 IF Z>B2 THEN 1040
829 REM - BYPASS DUPLICATE COORDINATES
830 IF Y(T+J)=Z THEN 860
839 REM - PLOT POINT
840 PRINT TAB(Z);"+";
850 Z=Y(T+J)
860 NEXT J
869 REM - TEST FOR OUT-OF-RANGE Y-COORDINATE
870 IF Z<0 THEN 1040
880 IF Z>B2 THEN 1040
889 REM - PLOT POINT
890 PRINT TAB(Z);"+";
900 GOTO 1040
910 S=T+L
919 REM - LOOP TO ESTABLISH PRINT FOR FIRST LINE
920 FOR J=0 TO B2
929 REM - POINT TO BE PLOTTED?
930 IF Y(S)<>J THEN 1010
939 REM - PLOT POINT
940 PRINT "+";
949 REM - BYPASS DUPLICATE COORDINATES
950 FOR K=S TO T+P-1
960 IF Y(K)=Y(S) THEN 990
970 S=K
980 GOTO 1020
990 NEXT K
1000 GOTO 1020
1009 REM - PLOT Y-AXIS
1010 PRINT "*";
1020 NEXT J
1029 REM - LABEL Y-AXIS
1030 PRINT "y";
1039 REM - ADVANCE OUTPUT DEVICE TO NEXT LINE
1040 PRINT
1050 NEXT I
1059 REM - LABEL X-AXIS
1060 PRINT "x"
1070 END
