1 COMMON A, AL, B, BASEONLY, C, C$, C1, CAT$, CC, CKT$, D, D$, DD, DIA, DIMN$, DMS, E, EO, EX$, F, F$, FD, FF, FQ, FRQ, G$, GO$, I, I$, L, LATLONG, LD, LL, LN, LS, LW, LX, MAX, MENU, MIN, MX, N, NN, NT, OV, P, PI, PROG$, Q, QQ, QU, R, RA, RC, T, T$, U, U$, UH, UL$, V$, VC, W, WHIP, WIRD, WW, X, X$, X1, XS, Z$, ZP, ZS
10 'SIMULEQ - Simultaneous equations - 24 OCT 1999
20 'ref:"57 Practical Programs & Games in BASIC", Radio Shack cat. no. 62-2008
30 CLS:KEY OFF
40 IF EX$=""THEN EX$="EXIT"
50 COLOR 7,0,1
60 UL$=STRING$(80,205)
70 DIM N(12)
80 '
90 '.....title page
100 CLS
110 COLOR 15,2
120 PRINT " SIMULTANEOUS EQUATIONS";TAB(57);"by George Murphy VE3ERP ";
130 COLOR 1,0:PRINT STRING$(80,223);
140 COLOR 7,0
150 '
160 '.....start
170 VIEW PRINT 3 TO 24:CLS:VIEW PRINT:LOCATE 3
180 PRINT " Press number in < >to:";
190 PRINT UL$;
200 PRINT "   <1> Solve equation with 2 unknowns of the type (AX + BY = C)";
210 PRINT "   <2> Solve equation with 3 unknowns of the type (AX + BY + CZ = D)";
220 PRINT
230 PRINT "   <0> EXIT";
240 Z$=INKEY$:IF Z$=""THEN 240
250 IF Z$="1"THEN 300
260 IF Z$="2"THEN 440
270 IF Z$="0"THEN CLS:RUN EX$
280 GOTO 240
290 '
300 '.....2 unknown
310 VIEW PRINT 3 TO 24:CLS:VIEW PRINT:LOCATE 3
320 PRINT TAB(9);"AX + BY = E"
330 PRINT TAB(9);"CX + DY = F"
340 PRINT:GOSUB 670
350 M=A*D-B*C
360 IF M=0 THEN 800
370 X=(E*D-B*F)/M
380 Y=(A*F-E*C)/M
390 PRINT
400 N=X:PRINT TAB(9);"X......";:GOSUB 770
410 N=Y:PRINT TAB(9);"Y......";:GOSUB 770
420 GOTO 850
430 '
440 '.....3 unknown
450 VIEW PRINT 3 TO 24:CLS:VIEW PRINT:LOCATE 3
460 PRINT TAB(9);"AX + BY + CZ = D"
470 PRINT TAB(9);"EX + FY + GZ = H"
480 PRINT TAB(9);"IX + JY + KZ = L"
490 PRINT:GOSUB 670
500 P1=B*E/A-F
510 P2=C*E/A-G
520 P3=B*I/A-J
530 P4=C*I/A-K
540 P5=P1*P4-P2*P3
550 IF P5=0 THEN 800
560 P6=D*E/A-H
570 P7=D*I/A-L
580 Y=(P6*P4-P2*P7)/P5
590 Z=(P1*P7-P6*P3)/P5
600 X=D/A-B/A*Y-C/A*Z
610 PRINT
620 N=X:PRINT TAB(9);"X......";:GOSUB 770
630 N=Y:PRINT TAB(9);"Y......";:GOSUB 770
640 N=Z:PRINT TAB(9);"Z......";:GOSUB 770
650 GOTO 850
660 '
670 '.....format
680 FOR Z=1 TO 12
690 IF Z$="1"AND Z>6 THEN 710
700 PRINT " ENTER: ";CHR$(Z+64);;"....";:INPUT N:GOSUB 760:N(Z)=N
710 NEXT Z
720 A=N(1):B=N(2):C=N(3):D=N(4):E=N(5):F=N(6):G=N(7)
730 H=N(8):I=N(9):J=N(10):K=N(11):L=N(12)
740 RETURN
750 '
760 LOCATE CSRLIN-1:PRINT STRING$(8,32);
770 LOCATE ,14:PRINT USING " ####,###.#####";N
780 RETURN
790 '
800 '.....error
810 BEEP:COLOR 12,0:PRINT " NO SOLUTION EXISTS or ERRONEOUS DATA ENTRY"
820 COLOR 7,0:PRINT " .....press any key....."
830 IF INKEY$=""THEN 830 ELSE 90
840 '
850 '.....end
860 GOSUB 880:GOTO 90
870 '
880 'PRT
890 KEY OFF:GOSUB 960:LOCATE 25,5:COLOR 0,2
900 PRINT " Send this page to:(1)Printer Queue? (2)Printout? ";
910 PRINT "(3)Next page? (1/2/3)";:COLOR 7,0
920 Z$=INKEY$:IF Z$<"1"OR Z$>"3"THEN 920 ELSE GOSUB 960
930 IF Z$="3"THEN RETURN
940 FOR I%=1 TO 24:FOR J%=1 TO 80:LPRINT CHR$(SCREEN(I%,J%));:NEXT J%:NEXT I%
950 IF Z$="2"THEN LPRINT CHR$(12) ELSE 890
960 LOCATE 25,1:PRINT STRING$(80,32);:RETURN
