(15C) (BASIC Computer Games) Train (by Walt Koetke)
06-16-2019, 11:20 PM
Post: #1
 Michael Zinn Member Posts: 56 Joined: Mar 2018
(15C) (BASIC Computer Games) Train (by Walt Koetke)
Source: https://www.atariarchives.org/basicgames...p?page=175

TRAIN is a program which uses the computer to generate problems with random initial conditions to teach about the time-speed-distance relationship (distance = rate x time). You then input your answer and the computer verifies your response.
TRAIN is merely an example of a student-generated problem. Maximum fun (and benefit) comes more from writing programs like this as opposed to solving the specific problem posed. Exchange your program with others -- you solve their problem and let them solve yours.
TRAIN was originally written in FOCAL by one student for use by others in his class. It was submitted to us by Walt Koetke, Lexington High School, Lexington, Mass.

BASIC
Code:
 1 PRINT TAB(33);"TRAIN" 2 PRINT TAB(15);"CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY" 3 PRINT: PRINT: PRINT 4 PRINT "TIME - SPEED DISTANCE EXERCISE": PRINT 10 C=INT(25*RND(1))+40 15 D=INT(15*RND(1))+5 20 T=INT(19*RND(1))+20 25 PRINT " A CAR TRAVELING";C;"MPH CAN MAKE A CERTAIN TRIP IN" 30 PRINT D;"HOURS LESS THAN A TRAIN TRAVELING AT";T;"MPH." 35 PRINT "HOW LONG DOES THE TRIP TAKE BY CAR"; 40 INPUT A 45 V=D*T/(C-T) 50 E=INT(ABS((V-A)*100/A)+.5) 55 IF E>5 THEN 70 60 PRINT "GOOD! ANSWER WITHIN";E;"PERCENT." 65 GOTO 80 70 PRINT "SORRY.  YOU WERE OFF BY";E;"PERCENT." 80 PRINT "CORRECT ANSWER IS";V;"HOURS." 90 PRINT 95 PRINT "ANOTHER PROBLEM (YES OR NO)"; 100 INPUT A$105 PRINT 110 IF A$="YES" THEN 10 999 END

HP 15-C Code
Code:
 001  LBL 0        | 42,21, 0 002  R/S          |       31 003  CF 8         | 43, 5, 8 004  RTN          |   43  32 005  LBL 1        | 42,21, 1 006  CHS          |       16 007  STO I        |   44  25 008  LBL 2        | 42,21, 2 009  GTO I        |   22  25 010  LBL 3        | 42,21, 3 011  CHS          |       16 012  x<>y         |       34 013  1            |        1 014  -            |       30 015  TEST 0       | 43,30, 0 016  RTN          |   43  32 017  R_down       |       33 018  STO I        |   44  25 019  R_up         |   43  33 020  RTN          |   43  32 021  LBL B        | 42,21,12 022  SF 8         | 43, 4, 8 023  0            |        0 024  GSB 0        |    32  0 025  SF 8         | 43, 4, 8 026  1            |        1 027  GSB 0        |    32  0 028  SF 8         | 43, 4, 8 029  0            |        0 030  GSB 0        |    32  0 031  SF 8         | 43, 4, 8 032  2            |        2 033  GSB 0        |    32  0 034  SF 8         | 43, 4, 8 035  3            |        3 036  GSB 0        |    32  0 037  2            |        2 038  5            |        5 039  RAN#         |   42  36 040  *            |       20 041  INT          |   43  44 042  4            |        4 043  0            |        0 044  +            |       40 045  STO 1        |    44  1 046  1            |        1 047  5            |        5 048  RAN#         |   42  36 049  *            |       20 050  INT          |   43  44 051  5            |        5 052  +            |       40 053  STO 2        |    44  2 054  1            |        1 055  9            |        9 056  RAN#         |   42  36 057  *            |       20 058  INT          |   43  44 059  2            |        2 060  0            |        0 061  +            |       40 062  STO 4        |    44  4 063  SF 8         | 43, 4, 8 064  4            |        4 065  GSB 0        |    32  0 066  RCL 1        |    45  1 067  GSB 0        |    32  0 068  SF 8         | 43, 4, 8 069  5            |        5 070  GSB 0        |    32  0 071  RCL 2        |    45  2 072  GSB 0        |    32  0 073  SF 8         | 43, 4, 8 074  6            |        6 075  GSB 0        |    32  0 076  RCL 4        |    45  4 077  GSB 0        |    32  0 078  SF 8         | 43, 4, 8 079  7            |        7 080  GSB 0        |    32  0 081  SF 8         | 43, 4, 8 082  8            |        8 083  GSB 0        |    32  0 084  SF 9         | 43, 4, 9 085  R/S          |       31 086  CF 9         | 43, 5, 9 087  STO 0        |    44  0 088  RCL 2        |    45  2 089  RCL 4        |    45  4 090  *            |       20 091  RCL 1        |    45  1 092  RCL 4        |    45  4 093  -            |       30 094  /            |       10 095  STO 5        |    44  5 096  RCL 5        |    45  5 097  RCL 0        |    45  0 098  -            |       30 099  1            |        1 100  0            |        0 101  0            |        0 102  *            |       20 103  RCL 0        |    45  0 104  /            |       10 105  ABS          |   43  16 106  .            |       48 107  5            |        5 108  +            |       40 109  INT          |   43  44 110  STO 3        |    44  3 111  1            |        1 112  3            |        3 113  3            |        3 114  CHS          |       16 115  STO I        |   44  25 116  5            |        5 117  RCL 3        |    45  3 118  TEST 7       | 43,30, 7 119  GTO I        |   22  25 120  SF 8         | 43, 4, 8 121  9            |        9 122  GSB 0        |    32  0 123  RCL 3        |    45  3 124  GSB 0        |    32  0 125  SF 8         | 43, 4, 8 126  1            |        1 127  0            |        0 128  GSB 0        |    32  0 129  1            |        1 130  4            |        4 131  3            |        3 132  GTO 1        |    22  1 133  SF 8         | 43, 4, 8 134  1            |        1 135  1            |        1 136  GSB 0        |    32  0 137  RCL 3        |    45  3 138  GSB 0        |    32  0 139  SF 8         | 43, 4, 8 140  1            |        1 141  0            |        0 142  GSB 0        |    32  0 143  SF 8         | 43, 4, 8 144  1            |        1 145  2            |        2 146  GSB 0        |    32  0 147  RCL 5        |    45  5 148  GSB 0        |    32  0 149  SF 8         | 43, 4, 8 150  1            |        1 151  3            |        3 152  GSB 0        |    32  0 153  SF 8         | 43, 4, 8 154  1            |        1 155  4            |        4 156  GSB 0        |    32  0 157  R/S          |       31

Memory Dump
Code:
 DM15_M1B 04  000000fffff000  00000000000008  0000000000000c  00000000000eae 08  00000000000000  2faf8befbe2280  00000000000000  00000000000000 14  00000000000000  1b2d2d2d2d2d2d  000000000002e6  00000000000000 18  00000000000000  0000000000007f  00000000a00000  00000000000000 e4  00000000000000  00000000000000  0000000000c220  f4f138ff20f3f1 e8  38ff203520f2f1  38ff20f0f138ff  203320f1f138ff  11f3f4f120f0f1 ec  38ff203320f938  ff887733f597c3  f3f3f143ebfaf5  c0b3fd30fcf0f0 f0  f1fb303545fdfb  3431fc34324049  ffc239ff20f838  ff20f738ff2034 f4  20f638ff203220  f538ff203120f4  38ff44faf0f2eb  fca1f9f142faf5 f8  ebfca1f5f141fa  f0f4ebfca1f5f2  20f338ff20f238  ff20f038ff20f1 fc  38ff20f038ff0b  b2b497c4b270fb  f1c5c303880297  c301b248ffc200 A: 000000fffff000  B: 000000fffffeae  C: 00000000000eae S: 00000000000000 M: 395033178ff000  N: 00000000000000  G: 04

How to use
This is a compiled BASIC program, compiled with voyc https://gitlab.com/michaelzinn/voyc.
You use it like this:
Code:
 | Calculator shows | Means                     | Do    | | :--------------: | :-----------------------: | :---: | |   Number         | The number shown          | Press R/S to continue | | Complex number   | The text with that number | Look up the text, then press R/S to continue | |   Blinking       | Input required            | Enter a number, then press R/S to continue (you don't have to press ENTER) |

Strings
Read the appropriate string when a complex number gets displayed:

Code:
 0: 1:    TRAIN 2:    CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY 3:    TIME - SPEED DISTANCE EXERCISE 4:     A CAR TRAVELING 5:    MPH CAN MAKE A CERTAIN TRIP IN 6:    HOURS LESS THAN A TRAIN TRAVELING AT 7:    MPH. 8:    HOW LONG DOES THE TRIP TAKE BY CAR 9:    GOOD! ANSWER WITHIN 10:    PERCENT. 11:    SORRY.  YOU WERE OFF BY 12:    CORRECT ANSWER IS 13:    HOURS. 14:    ANOTHER PROBLEM (YES OR NO)
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)