0 RANDOMIZE TIMER
1 REM **** GRAYSON WHEATLEY
2 REM **** PURDUE UNIVERSITY
3 REM **** THE COMPUTER WILL PICK A RULE OF THE FORM                   2*N + C. TO ALTER THE FORM OF THE RULE, CHANGE LINE 20.
5 PRINT "             WHAT'S MY RULE?"
6 PRINT "   I WILL MAKE UP A RULE. YOU  TRY TO GUESS IT."
7 PRINT "   YOU PICK A NUMBER.  I WILL SHOW YOU WHAT MY RULE GIVES.         AFTER YOU TYPE A NUMBER THEN PRESS   ENTER."
10 PRINT:PRINT"              TO PLAY HIT  ENTER."
12 PRINT:INPUT A$
19 Z=INT(RND(1)*3)+1
20 A = 0:B =INT(RND(1)*4)+2: GOTO 34
28 A=0:B=1:GOTO 34
31 C=-C
32 GOTO 200
34 C=INT(RND(1)*10)+1:SIGN=RND(2):ON SIGN GOTO 31,32
200 PRINT:PRINT"PICK A NUMBER.":INPUT N
205 GUESS=GUESS+1
206 IF Z=1 THEN ANSWER=B*N+C
207 IF Z=2 THEN ANSWER=(N/B)+C
208 IF Z=3 THEN ANSWER=(N^B)+C
210 PRINT"MY RULE GIVES ";ANSWER
215 PRINT:INPUT"HAVE YOU GUESSED MY RULE? (Y OR N)";Z$
220 IF Z$ = "Y" THEN 230 :ELSE 225
225 INPUT"DO YOU WANT ME TO TELL YOU THE RULE?(Y OR N)";K$
227 IF K$= "N" THEN 200 :ELSE 4000
230 PRINT:PRINT"O.K. I'LL GIVE YOU A NUMBER & YOU TYPE THE ANSWER."
232 CO=INT(RND(1)*15)+1:PRINT
235 PRINT"MY NUMBER IS";CO;". WHAT'S YOUR ANSWER?"
236 INPUT Q
237 IF Z=1 THEN ANSWER=B*CO+C
238 IF Z=2 THEN ANSWER=CO/B+C
239 IF Z=3 THEN ANSWER=CO^B+C
240 IF ANSWER=Q THEN 245 ELSE 260
245 PRINT"THAT'S RIGHT"
250 RIGHT=RIGHT+1:IF RIGHT=5 THEN 300
255 PRINT"TRY ANOTHER ONE":GOTO 232
260 INPUT"OOPS! WOULD YOU LIKE TO GUESS AGAIN? (Y OR N)";R$
270 IF R$ = "Y" THEN 230 :ELSE 280
280 INPUT "WOULD YOU LIKE TO STOP? (Y OR N)";U$
290 IF U$ = "Y" THEN 320 ELSE 200
300 PRINT"GOOD, YOU HAVE GUESSED MY RULE"
305 PRINT"DO YOU WANT TO TRY A NEW RULE? (Y OR N)"
310 A$= INKEY$:IF A$ = "" THEN 310 ELSE 315
315 IF A$ = "Y" THEN 20 ELSE 320
320 PRINT"THANKS FOR PLAYING. HAVE A NICE DAY.":END
4000 IF Z=1 THEN PRINT "THE RULE IS";B;"N +";C:GOTO 305
4010 IF Z=2 THEN PRINT "THE RULE IS N /";B;"+";C:GOTO 305
4020 IF Z=3 THEN PRINT "THE RULE IS N /";B;"+";C:GOTO 305
