10 REM Expert System Demo H. Bungay Oct 88 11 REM Modified by John C. Norton to provide an output file 12 REM output file is "output.txt" 15 KEY OFF 16 WIDTH 80 20 DIM B$(400), W(400), D(400) 30 CLS 35 OPEN "output.txt" FOR OUTPUT AS #1 40 PRINT " Expert System to Decide Who Pays" 45 PRINT #1, "OUTPUT>"; " Expert System to Decide Who Pays" 50 PRINT 55 PRINT #1, "OUTPUT>"; " " 60 PRINT "The program reads its DATA commands to generate this library:" 65 PRINT #1, "OUTPUT>"; "The program reads its DATA commands to generate this library:" 70 PRINT 75 PRINT #1, "OUTPUT>"; " " 80 PRINT " Name Weeks Since Payer Balance" 85 PRINT #1, "OUTPUT>"; " Name Weeks Since Payer Balance" 90 PRINT 95 PRINT #1, "OUTPUT>"; " " 100 W(0) = 0 110 X = 0 120 Y = 0 130 T = 0 140 FL = 1 160 X = X + 1 170 READ B$(X), W(X), D(X) 180 IF B$(X) <> "0" THEN PRINT B$(X), W(X), D(X) 185 IF B$(X) <> "0" THEN PRINT #1, "OUTPUT>"; B$(X), W(X), D(X) 190 IF B$(X) <> "0" THEN GOTO 160 200 INPUT "How many eligible persons at the table "; N 205 PRINT #1, "OUTPUT>"; "How many eligible persons at the table " 207 PRINT #1, " INPUT>"; N 210 FOR K = 1 TO N 220 PRINT "First initial and last name" 225 PRINT #1, "OUTPUT>"; "First initial and last name" 230 INPUT A$ 235 PRINT #1, " INPUT>"; A$ 240 FOR J = 1 TO X - 1 250 IF A$ = B$(J) THEN GOSUB 380 260 NEXT J 270 IF FL = 1 THEN PRINT A$; " can't pay. It is the first time" 275 IF FL = 1 THEN PRINT #1, "OUTPUT>"; A$; " can't pay. It is the first time" 280 FL = 1 290 NEXT K 300 PRINT 305 PRINT #1, "OUTPUT>" 310 PRINT "The person who has gone longest pays," 315 PRINT #1, "OUTPUT>"; "The person who has gone longest pays," 320 PRINT "unless there is a large positive balance." 325 PRINT #1, "OUTPUT>"; "unless there is a large positive balance." 330 PRINT 335 PRINT #1, "OUTPUT>" 340 PRINT "In this case, the payer is "; B$(Y); 345 PRINT #1, "OUTPUT>"; "In this case, the payer is "; B$(Y); 350 IF Y = 0 THEN PRINT " FLIP for it." 355 IF Y = 0 THEN PRINT #1, "OUTPUT>"; " FLIP for it." 357 CLOSE 360 STOP 380 FL = 0 390 PRINT " ", W(J), D(J) 395 PRINT #1, "OUTPUT>"; " " 400 IF W(J) > W(Y) AND D(J) < 5 THEN Y = J 410 RETURN 430 DATA Y. Urstruly,8,-44.44,J. Jones,5, 47.95,S. Spade,3,66.66,C. Gable,11,-2.95, P. Lomoco,1,99.50,J. Tightwad ,48,-112.24 440 DATA E. Fhutton,1,19.32,P. Ricketts,202,-8.95, U. Heep,63,2.10,C. Dickens,404,-43.21 450 DATA 0,0,0,0,0