32 Basic Programs For Trs-80 Level II
32 Basic Programs For Trs-80 Level II
5) ie ae ee : H
ye‘S f‘
fil,co yo
APPLICATIONS PROGRAMS
Biorhythm Checkbook Decide
Loan Mileage
EDUCATIONAL PROGRAMS
Arithmetic Flashcard Metric
Numbers _Tachist Vocab | GAME PROGRAMS
Decode Groan
Obstacle Roadrace
GRAPHICS PROGRAMS Jot Wari
Kaleido Sparkle
Squares Walloons
MATHEMATICS PROGRAMS
Curve Diffeqn Graph
Integrate Simeqn Stats
MISCELLANEOUS PROGRAMS
Birthday Pi
Powers Pythag
PHILLE sALKVas
dilithium Press
Portland, Oregon
© Copyright, dilithium Press, 1980
10 9 8 7 6 5 4 3 2 1
ISBN: 0-918398-27-4
Library of Congress catalog card number: 79-56399
dilithium Press
P.O. Box 92
Forest Grove, Oregon 97116
AN IMPORTANT NOTE
have learned a little about BASIC, you can go even further and
follow the suggestions about more extensive changes that can be
made. This approach was used to try to make every program
useful to you, whether you are a total beginner or an old hand
with computers.
But enough of the sales pitch. Our main point is that we feel
a computer is an incredibly flexible machine, and it is a shame
to put it to only one or two limited uses and let it sit idle the
rest of the time. We are giving you a pretty wide range of things
to do with your TRS-80, and we are really only scratching the
surface.
So open your eyes and your mind. Play a mental game against
the computer (WARI, JOT). Evaluate your next financial deci-
sion (LOAN, DECIDE). Expand your vocabulary or improve
your reading speed (VOCAB, TACHIST). Solve mathematical
equations (DIFFEQN, SIMEQN).
But please, don’t leave your TRS-80 asleep in the corner too
much. Give it some exercise.
BASIC Programs for the TRS-80
How to Use This Book
RECOMMENDED PROCEDURE
Section 6—MISCELLANEOUS
PROGRAMS
Short programs that do interesting things.
BIRTHDAY ~~ What are the odds of identical
birthdays in a group of people? 243
P| Calculate an approximation
Of pi. 247
POWERS Calculate powers of integers—
up to 250 digits long. 253
PYTHAG Generate Pythagorean triplets
(a? + b? = C?). 259
Bibliography 265
x Vili BASIC Programs for the TRS-80
section 1
Applications Programs
S2ty
BIORHYTHM
PURPOSE
Did you ever have one of those days when nothing seemed to
go right? All of us seem to have days when we are clumsy, feel
depressed, or just cannot seem to force ourselves to concentrate
as well as usual. Sometimes we know why this occurs. It may
result from the onset of a cold or because of an argument with a
relative. Sometimes, however, we find no such reason. Why
can’t we perform up to par on some of those days when nothing
is known to be wrong?
Biorhythm theory says that all of us have cycles, beginning
with the moment of birth, that influence our physical, emo-
tional, and intellectual states. We will not go into a lot of detail
about how biorhythm theory was developed (your local library
probably has some books about this if you want to find out
more), but we will summarize how it supposedly affects you.
The physical cycle is twenty-three days long. For the first
11% days, you are in the positive half of the cycle. This means
you should have a feeling of physical well-being, strength, and
endurance. During the second 11% days, you are in the negative
half of the cycle. This results in less endurance and a tendency
toward a general feeling of fatigue.
The emotional cycle lasts for twenty-eight days. During the
positive half (the first fourteen days), you should feel more
cheerful, optimistic, and cooperative. During the negative half,
you will tend to be more moody, pessimistic, and irritable.
The third cycle is the intellectual cycle, which lasts for
thirty-three days. The first half is a period in which you should
4 BASIC Programs for the TRS-80
HOW TO USE IT
The program first asks for the birth date of the person whose
biorhythm cycles are to be charted. You provide the month and
day as you might expect. For the year, you only need to enter
the last two digits if it is between 1900 and 1999. Otherwise,
enter all four digits.
Next the program asks you for the start date for the biorhythm
chart. Enter it in the same way. Of course, this date cannot be
earlier than the birth date.
After a delay of about asecond, the program clears the screen
and begins plotting the biorhythm chart, one day at a time. The
BIORHYTHM 5
left side of the screen displays the date, while the right side dis-
plays the chart. The left half of the chart is the ‘“down”’ (negative)
side of each cycle. The right half is the “up’’ (positive) side. The
center line shows the critical days when you are at a zero point
(neither positive or negative).
Each of the three curves is plotted with an identifying letter—
P for physical, E for emotional, and I for intellectual. When the
curves cross, an asterisk is displayed instead of either of the two
(or three) letters.
Twelve days of the chart are displayed on one screen, and
then the program waits for you to press a key. If you press the
E key, the current chart ends and the program starts over again.
If you press the SPACE key (or any other key except BREAK or
SHIFT), the program clears the screen and displays the next
eighteen days of the chart.
The program will allow you to enter dates from the year
100 A.D. and on. We make no guarantees about any extreme
future dates, however, such as entering a year greater than
3000. We sincerely hope that these limitations do not prove to
be too confining for you.
SAMPLE RUN
Ot
secu ls
MONTH (1 TO 12)? 1
DAY (1 10 31)? 3%
sid: Cand
1947 ASSUMED.
I Ue aa ad
MONTH (i TO 12)? 4
DAY (1 10 31)?1
YEAR? 79
eel28
The operator enters his or her birth date and the date for the beginning of
the chart
6 BASIC Programs
for the TRS-80
dt
= TTL f " P
OOOO
Wi ld E I
vey iad I
Cia Mae 4 id I
rn? id |
nee P
I
Vero o£ id I
7s an 3 id i
bed E lg
479/79 13 Pp I
418/79 13 iy
aba) 3 I 4
ate ie E I P
SRAM PARP
LL
The program responds with the first 12 days of the operator's biorhythm
chart, then waits for a key to be pressed.
PROGRAM LISTING
189 REM: BIORHYTHM
119 REM: COPYRIGHT 1979 BY TOM RUGG AND PHIL FELDMAN
129 CLEAR 2@0:DEF INT K,L:QEFUBL B,J,M-Z
136 L=@:T=25sP=3.1415926535 CLS
149 PRINT TABC1S) 5"BIORHYTHM" sPRINT
15@ PRINT"ENTER BIRTH DATE"
148 GOSUB 599
178 GOSUR 499
188 JB=JD
19@ PRINTSPRINT"ENTER START DATE FOR CHART"
299 GOSUBR 599
218 GOSUB 699
229 JCsJD
238 IF JC2=JB THEN 279
248 PRINT"CHART DATE CAN°T BE EARLIER THAN"
259 PRINT’RIRTH DATE. TRY AGAIN."
268 GOTO 1598
278 FOR K=1 TO 168@:NEXT
289 GOSUB 789
398 N=JC-JB
BIORHYTHM 7
EASY CHANGES
MAIN ROUTINES
MAIN VARIABLES
W, B Work variables.
R Remainder of N/V (number of days into cycle).
A$ Work variable.
SUGGESTED PROJECTS
PURPOSE
HOW TO USE IT
This will generally be the highest numbered check the bank has
processed, unless you like to write checks out of sequence.
Your account balance after this most recent check will be
reconciled with the statement balance, so that is what the pro-
gram asks for next—your checkbook balance after the most
recent check.
The program must compensate for any differences between
what your checkbook has in it prior to the most recent check
and what the statement has on it. First, if you have any deposits
that are not shown on the statement before the most recent
check, you must enter them. Generally, there are none, so you
just enter ““END.”’
Next you have to enter the amounts of any checks that have
not yet “‘cleared”’ the bank and that are prior to the most recent
check. Look in your checkbook for any checks that do not have
your check mark next to them. Remember that some of these
could be several months old.
Next you enter the amount of any service charges or debit
memos that are on the statement, but which have not been
shown in your checkbook prior to the most recent check.
Typically, this is just a monthly service charge, but there
might also be charges for printing new checks for you or some
other adjustment that takes money away from you. Credit
memos (which give money back to you) are not entered until
later. Be sure to make an entry in your checkbook for any of
these adjustments so that next month’s statement will balance.
Finally, you are asked for any recent deposits or credit
memos that were not entered in your checkbook prior to the
most recent check, but that are listed on the bank statement. It
is not unusual to have one or two of these, since deposits are
generally processed by banks sooner than checks.
Now comes the moment of truth. The program tells you
whether or not you are in balance and displays the totals. If so,
pack things up until next month’s statement arrives.
If not, you have to figure out what is wrong. You have seven
options of what to do next which allow you to review the num-
bers you entered in case of a typing error. If you find an error,
go back to the beginning and try again. Of course, if it is a simple
error that precisely accounts for the amount by which you are
out of balance, there is no need to go through the whole thing
again.
CHECKBOOK 13
SAMPLE RUN
CHECKBOOK BALANCER
TOTAL = 45.94
ND
v
mM
TOTAL = 5
TOTAL = @
CONGRATULATIONS! IT BALANCES.
DIFFERENCE = §@
NEXT ACTION:
- LIST CHECKS OUTSTANDING
DO oF
- START OVER
- END PROGRAM
UT
PROGRAM LISTING
#38 INPUT RS
749 TF RS="ENU" THEN 889
Pg TF VAL CRS) 2@ THEN 779
74 FRINTsPRINT ESsG0TO #29
27B NS=NS+7 SONS) eUGL CRS) 2 TS=TS+S (NS)
789 TF NS=M5 THEN 27.49
796 FRINTsPRINT L&sFRINT
896 PRINTSPRINT TOTAL ="eTSsPRINT
Bas GOSUBR 2989
8192 WeSR+TN+TS-Ca-TC~TR sW=ARS (CW)
O15 TF W..981 THEN W=8 ELSE GOTO 84¢
B29 PRINT'CONGRATULATIONS! IT BALANCES."
83 GOTO 859
B49 PRINT SORRY. [f°S OUT OF BALANCE."
Boy FRINT
34d PRINT 'STATENMENT BALANCE + DEPOSITS OUTSTANDING"
3,73 FRINT’+ SERVICE CHARGES =" SR+T0U+TS
889 PRINT
BPM PRINT? CHECK BOOK BALANCE + CHECKS QUTSTANDING"
9G PRINT+ RECENT UEPOSETS ="SCR+TC+TR
918 PRINT
978 PRINT UOTFFERENCE ="5
Pe PRINT&EPRINT PRESS ANY KEY TO CONTINUE”
238 TF INKEYS="" THEN 944
oan PRINT
FAG PRINT NEXT ACTIONS"
950 FRINT" 1 LIST CHECKS OUTSTANDING"
i
MAIN ROUTINES
MAIN VARIABLES
SUGGESTED PROJECTS
PURPOSE
HOW TO USE IT
The first thing the program does is ask you to categorize the
decision at hand into one of these three categories:
1) Choosing an item (or thing),
2) Choosing a course of action, or
3) Making a yes or no decision.
You simply press 1, 2, or 3 to indicate which type of decision is
facing you. (It is not necessary to hit the ENTER key.) If you
are choosing an item, you will be asked what type of item it is.
22 BASIC Programs for the TRS-80
If the decision is either of the first two types, you must next
enter a list of all the possibilities under consideration. A question
mark will prompt you for each one. When the list is complete,
type ““END” in response to the last question mark. You must,
of course, enter at least two possibilities. (We hope you don’t
have trouble making decisions from only one possibility!) After
the list is finished, it will be re-displayed so that you can verify
that it is correct. If not, you must re-enter it.
Now you must think of the different factors that are important
to you in making your decision. For example, location, cost,
and quality of education might govern the decision of which
college to attend. For a refrigerator purchase, the factors might
be things like price, size, reliability, and warranty. In any case,
you will be prompted for your list with a succession of question
marks. Each factor is to be entered one at a time with the word
‘““END”’ used to terminate the list. When complete, the list will
be re-displayed. You must now decide which single factor is the
most important and input its number. (You can enter 0 if you
wish to change the list of factors.)
The program now asks you to rate the importance of each of
the other factors relative to the most important one. This is
done by first assigning a value of 10 to the main factor. Then
you must assign a value from QO - 10 to each of the other factors.
These numbers reflect your assessment of each factor’s relative
importance as compared to the main one. A value of 10 means
it is just as important; lesser values indicate how much less
importance you place on it.
Now you must rate the decision possibilities with respect to
each of the importance factors. Each importance factor will be
treated separately. Considering only that importance factor,
you must rate how each decision possibility stacks up. The
program first assigns a value of 10 to one of the decision possi-
bilities. Then you must assign a relative number (lower, higher,
or equal to 10) to each of the other decision possibilities.
An example might alleviate possible confusion here. Suppose
you are trying to decide whether to get a dog, cat, or canary for
a pet. Affection is one of your importance factors. The program
assigns a value of 10 to the cat. Considering only affection, you
might assign a value of 20 to the dog and 6.5 to the canary. This
means you consider a dog twice as affectionate as a cat but a
canary only about two thirds as affectionate as a cat. (No
DECIDE 23
SAMPLE RUN
DECIDE
MOUNTAIN CAMPING
oD
AFRICAN SAFARI
9D
END
"2
1) MOUNTAIN CAMPING
2) AFRICAN SAFARI
3) TRIP TO WASHINGTON D.C.
RELAXATION
oD
AFFORDABILITY
oD
CHANGE OF PACE
DO
END
VO
1) RELAXATION
2) AFFORDABILITY
3) CHANGE OF PACE
2? 2
RELAXATION
2? 5.5
CHANGE OF PACE
? 9
PROGRAM LISTING
EASY CHANGES
MAIN ROUTINES
MAIN VARIABLES
SUGGESTED PROJECTS
PURPOSE
HOW TO USE IT
The program first asks you the size of the loan you are con-
sidering. Only whole dollar amounts are allowed—no pennies.
Loans of ten million dollars or more are rejected (you can
afford to hire an investment counselor if you want to borrow
that much). Then you are asked the yearly interest rate for the
loan. Enter this number as a percentage, such as “10.8”. Next,
you are asked to give the period of the loan in months. For a five
year loan, enter 60. For a thirty year mortgage, enter 360. The
program then displays this information for you and calculates
34 BASIC Programs for the TRS-80
the monthly payment that will cause the loan to be paid off
with equal payments each month over the life of the loan.
At this point you have four options. First, you can show a
monthly analysis. This displays a month-by-month breakdown,
showing the state of the loan after each payment. The four
columns of data shown for each month are the payment number
(or month number) of the loan, the remaining balance of the
loan after that payment, the amount of that payment that was
interest, and the accumulated interest paid to date. Twelve lines
of data are displayed on the screen, and then you can either
press the T key to get the final totals for the loan, or any other
key to get the data for the next twelve months of the loan.
The second option is overriding the monthly payment. It is
a common practice with second mortgage loans to make smaller
monthly payments each month with a large “balloon”? payment
as the final payment. You can use this second option to try
various monthly payments to see how they affect that big pay-
ment at the end. After overriding the monthly payment, you
will want to use the first option next to get a monthly analysis
and final totals using the new monthly payment.
The third option is to simply start over. You will generally
use this option if you are just comparing what the different
monthly payments would be for different loan possibilities.
The fourth option ends the program.
By the way, there is a chance that the monthly payment
calculated by your lender will differ from the one calculated
here by a penny or two. We like to think that this is because we
are making a more accurate calculation.
SAMPLE RUN
LOAN CALCULATOR
ee eae
233) ee ee)
LENGTH OF LOAN (MONTHS)? 368.
The operator enters the three necessary pieces of information about his or
her loan.
Pe eae eee lf
MONTHLY PAYMENT IS 368.85
NEXT ACTION:
1 - SHOW MONTHLY ANALYSIS
2 — OVERRIDE MONTHLY PAYMENT
ciemel(.1i 2 4
4 - END
pa
The program responds with the monthly payment that will pay off the
loan with equal payments over its life, then asks the operator what to do
next. The operator asks for the monthly analysis.
BASIC Programs for the TRS-80
Peee ea 83
REMAINING © ——INTEREST——
Pree tod Pete a
41908.48 341.5 341.5
ens] ve ee RD
ers CR ee A
oe SO
ee CO
Veo
ee CO Se A)
ee] ce <8)
TEs ey e/a 3
Cea. SOAR
OCA, KS OI
417%.68 339.77 345.18 -
mm
>
The program responds with information about the first twelve months of
the loan, then waits.
The operator presses ‘‘T’’, and after a few seconds the program displays
totalling information about the loan.
LOAN 37
PROGRAM LISTING
J98 PT=T/199
609 T2=TT/199
618 PRINT J; TABCS),.
615 PRINT USING HHHHHHHH .HH-" SPBSPT; 12
61/7 IF B=@ THEN JENsGOTO 639
629 |L=L+1sIF Lsi2 THEN 669
639 PRINT'PRESS “T~ FOR TOTALS, ANY OTHER
KEY TO CONTINUE":
649 R$=INKEYS:IF R$="'"" THEN 649
659 L=@:GOSUB 459:
IF R$="T" THEN PRINT'CALCULATING TOTALS..."
6469 NEXT
678 PRINT:PRINT"LAST PAYMENT ="5P/199
589 PRINT" TOTAL PAYMENTS ="STF/19¢
699 PRINT’ MONTHLY FAYMENT WAS" SFF
719 PRINTsPRINT'PRESS ANY KEY TO CONTINUE"
229 RS=INKEYSsIF RG="" THEN 72¢
738 P=FPsGOTO 249
899 CLS
819 PRINT As"FOR’ SN; "MONTHS AT" SRS"PER CENT"
838 RETURN
1899 A=ABS(A) sA=INT(A)
1919 IF AX18999998 THEN RETURN
1928 PRINT’ TO0 LARGE"
1930 A=OsRETURN
2999 P=P+R:TP=TP+B2B=6
2919 RETURN
EASY CHANGES
MAIN ROUTINES
MAIN VARIABLES
Amount of loan.
Interest rate (percentage).
Length of loan (number of months).
Monthly interest rate (not percentage).
Work variable.
Monthly payment (times 100).
First monthly payment.
Choice of next action.
Remaining balance of loan (times 100).
Total interest to date (times 100).
Total payments to date.
Number of lines of data on screen.
Reply from operator at keyboard.
Work variable for loops.
Monthly interest.
Remaining balance to be displayed (two decimal
places).
PT Monthly interest to be displayed (two decimal
places).
T2 Total interest to be displayed (two decimal places).
SUGGESTED PROJECTS
PURPOSE
HOW TO USE IT
SAMPLE RUN
MILEAGE
COMMAND LIST
- READ OLD MASTER FILE FROM CASSETTE
re
DATE? 9/28/78
ODOMETER? 5151.1
# GALLONS? 14.6
-~ IS INPUT OK ? -
DATE?
(a key is pressed)
(the five commands are listed again)
ENTER COMMAND BY NUMBER? 3.
(a subsequent run)
PROGRAM LISTING
198 REM: MILEAGE
119 REM: COPYRIGHT 1979 BY PHIL FELIMAN AND TOM RUGG
1298 CLEAR 299
138 MW= 15 sMR=29 sN=d
149 CIM DS (MR) DCM) ,G(MR) JM (MR) sB$=""
138 CLO:R=@:PRINT TAB(25)2"MILEAGE" :PRINTs
PRINT"COMMAND LIST"
169 PRINT" 1 - READ OLD MASTER FILE FROM CASSETTE"
178 PRINT" 2 - INPUT DATA FROM THE TERMINAL”
189 PRINT’ 3 - WRITE NEW MASTER FILE TO CASSETTE"
199 PRINT 4 - DISPLAY MILEAGE DATA"
298 PRINT’ S ~- TERMINATE PROGRAM’ sPRINT
219 INFUT" ENTER COMMAND BY NUMBER" SR:
IF R“1 OR RYS THEN 1598
229 ON R GOSUB 769,390,509,4608,899:GOTO 159
399 IF N=MR THEN 479
319 PRINTSPRINT"ENTER THE FOLLOWING [IATA AS REQUESTED"
529 PRINT" - DATE (E.G. 1/30/79)"
538 PRINT" ~ OUOMETER READING (MILES)"
549 FRINT" - # GALLONS BOUGHT"
559 N=N+1 PRINTS INPUT'DATE" SR$2RS=LEFTS (R$, 8) 11S (NERS
549 INPUT"ODOMETER" SRiD(N)=RiIF RG THEN 348
379 INPUT"H GALLONS" SR:G(N)=REIF R<@ THEN 376
389 PRINT:PRINT TAB(3) s"INFUT DATE: "s$(N)
398 PRINT TAB(3) s"CHECK ODOMETER: "STN:
PRINT TAB(13) "GALLONS" 3G(N)
499 PRINT:PRINT" -~ I$ INPUT OK ? -"sPRINT
419 INPUT" (Y=YES, N=NO, F=YES AND FINISHED) "sR$:
R$=LEFTS$(R$,1)
429 IF R$="N" THEN N=N-12PRINT!FRINT" REDO LAST DATA":
GOTO 35¢
439 IF R$="F" THEN RETURN
449 TF R#<>"Y" THEN 409
450 IF N=MR THEN 479
460 GOTO 359
478 PRINT sPRINT'dee NO MORE DATA ALLOWED :GOSUB 920:
RETURN
509 IF Nel THEN PRINT:PRINT’&* NO DATA TO WRITE":
GOSUB 926:RETURN
Jd R$="WRITING" :GOSUB 858sPRINT
46 BASIC Programs for the TRS-80
EASY CHANGES
MAIN VARIABLES
SUGGESTED PROJECTS
1. Calculate and print the average MPG over the whole data file.
The total miles driven is D(N)— D(1). The total gallons used
is the sum of G(J) for J=2 to N. This calculation can be done
at the end of the DISPLAY MILEAGE subroutine. Program-
ming should be done between lines 670 and 680.
2. Allow the user the option to write to cassette only the entries
since a certain date. Ask which date and search the D$ array
for it. Then set MW to the appropriate number of records to
write. These changes are to be made between lines 500 and
510 at the beginning of the subroutine to write on cassette.
3. Add a new command option to verify a data file just written
to cassette. It would read the tape and compare it to the
data already in memory.
4. Add an option to do statistical calculations over a given sub-
set of the data. The operator inputs a beginning and ending
date. He is then shown things like average MPG, total miles
driven, total gallons purchased, etc.; all computed only over
the range requested.
5. Write a subroutine to graphically display MPG. A bar graph
might work well.
6. Add a new parameter in each data record—the cost of each
fill-up. Then compute things like the total cost of gasoline,
miles/dollar, etc.
QUEST/EXAM
PURPOSE
HOW TO USE IT
Now the program asks you to begin providing the answers for
each entry. Again, guide numbers are displayed above the area
where you are to enter the data so you can more easily provide
the proper answer for the proper question number. If no answer
was given for a particular question, leave a blank space. However,
if either the first or the last question was left blank, you will
have to enclose the entire string of answers within quotation
marks. This will cause a small problem in keeping your alignment
straight with the guide numbers, but you’ll get used to it. See
the Sample Run for an example.
If you make a mistake when entering the data, the program
will tell you and ask you to re-enter it. This is most commonly
caused by either failing to enter the correct number of answers
or entering an invalid character instead of an acceptable answer
number. Remember that each answer must be either a blank or
a number from one to the number of choices you allowed per
question.
By the way, you can avoid entering blanks for unanswered
questions. Suppose you have a maximum of 5 possible answers
per question. Simply tell the program there are 6 choices per
question. Then, when a question is unanswered, you can enter a
6 instead of leaving it blank.
If you specified that you wanted names for each entry, the
program asks you for the name after you have entered the
answer key. Do not use commas in the name unless you enclose
the entire name in quotation marks.
If you provided an answer key, the program displays the
number and percentage correct after each entry before going on
to ask for the next one. When you have no more entries, press
the ENTER key instead of entering a string of answers.
At this point, the program displays five options from which
you choose your next action. Here are brief explanations. You
can experiment to verify how they work.
Option one lets you analyze each question, to see how many
people responded with each answer. The percentage of people
who responded with each answer is also shown. In the case of
an exam, the right answer is indicated with the word ““RIGHT.”
Option two allows you to go back and provide more entries.
This allows you to pause after entering part of the data, do
some analysis of what you have entered so far, and then go back
and continue entering data.
QUEST/EXAM 51
Option three lets you review what you have entered, including
the answer key. This permits you to check for duplicate, omitted,
or erroneous entries.
Option four starts the program over at the beginning again,
and option five ends the program.
SAMPLE RUN
1 2
1234567890 1234567898
PRS tak acl x, ara
ENTRY NUMBER 1
1 2
ere Ms dees5]
2 3322302144421 121341
Pea em ae
enact)
A a Sf
aaa laa
1 2
Wee Mee OCA My
B
The answers are entered for the first student, followed by the student’s
name. The program responds with the number and percentage correct.
Pamel A0e Es 3)
3.
raya
ta 2
1 rd
NRA acy SUK se)
4
AYERAGE
= 82.5 PERCENT
NEXT ACTION:
1 - ANALYZEEACH QUESTION
LMS a3
ei) (2 BUC (33)
Semi. mt 3
Sie e |
1
Later, instead of providing data for a ninth student, the operator presses
the ENTER key, indicating no more entries. The program displays the
overall percentage correct, and displays a ‘‘menu” of choices of actions.
The operator picks number one.
QUEST/EXAM
Pee ala
eee ag Cea)
Pema: Aid
eee ery
1
5 - END PROGRAM
1 ia
RRL tae Oka sab)
33124321443422121341—ANSHER KEY
33223321443421 1213410. 1 J ANDERSON
RS k aC Saati tee)
3321442234242 12°331—-ND. 3 R FORBES
Rea C x0. x aes iG Re. aif
estes rats waa ete) a
Restos sea ee Big Ect
13124221433420121344—NO. 7 K VANFLEET
BSR ROR Sco tk see Me 2)
ose AMMEN 2
Later, the operator asks for option number 3, which lists the data entered
for each of the students.
54 BASIC Programs for the TRS-80
PROGRAM LISTING
199 REM: QUESTIONNAIRE/EXAM ANALYZER
119 REM: COPYRIGHT 1979 BY TOM RUGG AND) PHIL FELDMAN
120 CLEAR 7@9:CLS:DEFINT C-W
139 PRINT" cee EXAM/QUESTIONNAIRE ANALYZER :ettek" sPRINT
149 E$="sekk ERROR. RE-ENTER. dete!’
P$="PRESS A KEY TO CONTINUE"
15@ INPUT"NUMBER OF QUESTIONS":Q
149 IF Q<1 OR Q>5@ THEN 159
174 INPUT"CHOICES PER QUESTION’SC
189 IF C<2 OR C>9 THEN 178 ELSE DIN C(C)
199 INPUT"MAXIMUM NUMBER OF ENTRIES"sN
296 IF N<1 THEN 199 ELSE DIM Q$(N)
219 INPUT"WANT NAMES FOR EACH ENTRY" sR$
226 RS$=LEFT$(R$,1)2IF R$="N" THEN 256
239 IF R$<>"Y" THEN 219
249 TIM NS(N)
256 PRINT:
PRINT'ENTER ANSWER KEY. IF NONE, PRESS “ENTER’."
260 GOSUR 900:A$="" :C$=RIGHTS(STRB(C),1)
319 INPUT A$:IF LEN(A$)=@ THEN A$=""sGOTO 349
326 IF LENCA$)<2Q THEN PRINT E$:GOTO 259
339 T$=A$:GOSUR SS@:IF T#="B" THEN PRINT E$:GOTO 259
349 K=1
350 R=OsPRINT:PRINT"ENTRY NUMBER"SK
366 GOSUB 999
376 INPUT Q$(K) :W=LEN(Q$(K))
389 IF W=@ THEN 599
399 IF WoQ THEN PRINT E$:GOTO 359
490 T$=0$(K):GOSUB 850:IF T$="B" THEN PRINT E$:GOTO 359
416 IF R$="N" THEN 430 ELSE
PRINT'NAME FOR ENTRY NUMBER"SK
420 INPUT N$(K)2IF LEN(NS(K))=@ THEN N$(K)=""
436 IF A$="" THEN 489
449 FOR J=1 TO Q
450 IF MIDS(A$,J,1)=MID$(Q$(K),J,1) THEN R=R+1
469 NEXT
476 TR=TR#RPRINT Ri"CORRECT,",R#190/Q5 "PERCENT"
ABO K=K+1:IF K“=N THEN 359
509 K=K-12IF A$=""" THEN 52d
S10 PRINTPRINT"AVERAGE ="sTR#199/ (GK) s"PERCENT"
529 GOTO 949
538 PRINT:FOR J=1 TO Q
S49 R=G:PRINT:PRINT"ANALYSIS FOR QUESTION NO."J
545 PRINT'RESPONSE", "COUNT", "PERCENT"
QUEST/EXAM 55
EASY CHANGES
MAIN ROUTINES
120
- 140 Initializes variables.
150
- 240 Performs initialization dialog. Selects options.
Allocates arrays.
250 - 320 Gets answer key (if any) from operator.
330 Checks legality of answer key.
350 - 400 Gets exam data for Kth entry.
410 - 420 Gets name for Kth entry, if applicable.
430 - 470 Scores Kth exam, if applicable.
500 - 510 Displays average score, if an exam.
530 - 690 Analyzes responses to each question.
700 - 790 Displays data entered.
850 - 880 Subroutine to check legality of input data.
900 - 940 Subroutine to display guide numbers over input
data area.
960- 1100 Displays choices for next action. Gets response
and goes to appropriate routine.
MAIN VARIABLES
E$ Error message
P$ Message about pressing a key to continue.
Q Number of questions (1 - 50).
C Number of choices per question (2 - 9).
C Array for tallying number of people responding
with each choice.
N Maximum number of entries.
Q$ Array of N strings of entries.
R$ Set to N if no names for each entry, or Y other-
wise.
N$ Array of Q names (if R$ is Y).
QUEST/EXAM 57
SUGGESTED PROJECTS
1. Add an option to change the answer key after the data for
the exams is entered. This would be useful in case a mistake
was found when reviewing the data.
2. Add an option to allow the operator to re-score each of the
exams after all are entered, in case some were overlooked at
the time of entry.
3. Combine some of the capabilities of the STATS program
with this one.
58 BASIC Programs for the TRS-80
section 2
Educational Programs
PURPOSE
HOW TO USE IT
SAMPLE RUN
ARITHMETIC
ARITHMETIC
The initial set of 4 problems is presented. With a question mark, the pro-
gram prompts the operator for the answer to the first problem.
64 BASIC Programs for the TRS-80
ARITHMETIC
63 =
+ 17 ae 3
CC
Fs15) 148
ANSWERS
88 es re 54
RIGHT! RIGHT! RIGHT! WRONG!
HIT ANY KEY TO CONTINUE
The operator has entered his or her four answers. The program displays the
correct answers and indicates whether or not each problem was solved
correctly. The program waits for the operator to hit any key in order to
continue with the next set of four problems.
PROGRAM LISTING
EASY CHANGES
MAIN ROUTINES
MAIN VARIABLES
R Work variable.
J,K Loop indices.
P Screen position, also percentage correct.
SUGGESTED PROJECTS
PURPOSE
HOW TO USE IT
The program gives you seven options. The first time you run
it, you'll want to enter new flashcards, so you should reply with
number 1.
To create the cards, the program asks you for each side of
each flashcard, one at a time. First enter side one of the first
card, and so on. As you enter the data, be careful not to use any
70 BASIC Programs for the TRS-80
SAMPLE RUN
FLASHCARD PROGRAM
LIMIT IS 12 CARDS
----OPTIONS----
1 - ENTER NEW FLASHCARDS
2 - LOAD A FLASHCARD TAPE
3 - SAVE CURRENT SET ON TAPE
4 - DRILL ON CURRENT SET
5 - VERIFY FLASHCARDS ON TAPE
6 — ADD TO CURRENT CARDS
7 - END PROGRAM
? 1
SIDE ONE OF CARD NO. 1
2? THE PEN
SIDE TWO
? LA PLUMA
-~---OPTIONS----
- ENTER NEW FLASHCARDS
Fr
THE DOOR
? LA PUERTA
RIGHT!
LA PLUMA
? THE PEN
RIGHT!
THE FLOOR
? LA ESCUELA
THE SCHOOL
? LA ESCUELA
RIGHT!
LA TIENDRA
? SEND
FLASHCARD 73
3 RIGHT OUT OF 4
75 PER CENT
PROGRAM LISTING
188 REM: FLASHCARD
118 REM: COPYRIGHT 1979 BY TOM RUGG AND PHIL FELIMAN
128 CLEAR 24@sNEFINT A-ZsN=-1
138 L=12sM=5
148 TIM FS(h) »BSCL) PMT)
158 RANDOMSCLSOSE$=""4e ERROR cet"
168 We='se+ PRESS “STOP” KEY ON RECORDER st"
178 FRINT’FLASHCARD FROGRAM"
186 PRINTSPRINT"LIMIT IS" SLs "CARUS.":G0TO 24d¢
198 Ket sWe@ eC dsPRINT
248 FSCK 2" "SPRINT STE ONE OF CARTE NO. SREINPUT FECK)
205 TF LENCFS¢K)=@ THEN PRINT E€sGOTOQ 208
219 TF LEFTS(FSCK) 4)="4END" THEN 28d
220 IF LEFTS(FS(K) a) ai ‘"' THEN 2398
222 K=K-1TsIF ket THEN Ks
20 PRINTsPRINT’ BACKING Wp" 6070 296
39 BECK)" "SPRINT SIDE TWO"SINFUT RSCK)
3% IF LENCBS(k))=@ THEN PRINT ESsGOTO 23:
49 IF LEFTS(RS(K),S)="kBACK" THEN 225
JO PRINT
46 Kek+1s0F Kes ‘l. THEN 230
2°60 PRINT THATS THE’ SLs "CARD LIMIT."
239 FRINTskK=K-1 sG0TO 2006
296 IF Ke=M THEN 314
34@ FRINT ES3" MINIMUM TS" SMe CARTS .°sGOTO 2000
319 PRINTSPRINT’ TELL ME WHATS ON THE”
328 PRINT 'OTHER SI0k OF EACH CARH AS I SHOW IT."
3349 FRINT
346 ReRNDCKOSFOR Je@ TO M-2sTF POD=R THEN 349
399 NEXTsJ=RNDC2Q)2IF J=2 THEN 429
496 PRINT FS(R) sC$=BS(R) 2G0TO 439
429 PRINT RS$(R)sC$=F$(R)
438 R=" "Ss INPUT RS
446 IF LEFTS(R$,4)="#ENU" THEN 6960
459 FRINT
460 IF R*=C$ THEN 39d |
4/7@ PRINT'NO, THE CORRECT RESPONSE IS”
460 PRINT C$
499 W=W+1sGOTO S28
348 PRINT' RIGHT!"
74 BASIC Programs for the TRS-80
wld CaC+4
woe FOR J=1 TO M-2rF(J-1)=F (1) sNEXT EF OM-2)2REPRINT
wag GOTO 349
490 GOSUB 1586:GOTO 2009
708 IF Ket THEN 188
718 GOSUB 1499
P29 PRINT'PRESS “RECORT” AND “PLAY” BUTTONS, THEN"
736 PRINT'PROVIDE NAME FOR FILE WHEN READY." sINPUT NS
23S PRINT'WRITING "INS
JAG PRINTHN NSZPRINTHN, STRE(K)SFOR Jet TO K
Pu PRINTHN FS (1) RSC)
769 PRINT JtsNEXT
779 PRINTHN, "END"
799 PRINTIF RINT" DONE”
889 PRINT Wt
B18 GOTO 2009
996 E=@:GOSUB 1499
9198 PRINT'PRESS “PLAY”. THEN PRESS ANY KEY."
929 RS=INKEY$:IF R$=""" THEN 926
930 PRINT'SEARCHING FOR "INS
93 INFUTHN RSIIF R&=N$ THEN 959
949 PRINT'FOUND "AR$:
IF R$="#ENIU' THEN 939 ELSE GOTO 93%
wd PRINTSPRINTFQUND "tN: INFUTHN, RS
949 IF VALCRS)<>K THEN E=1t:PRINT E$2" RAD COUNT":
GOTO 1929
976 FOR J=1 TO KeINFUTHN,RS,74
PPS PRINT R&sPRINT 1%
989 TF R&<eF$(J) OR TH2B341) THEN E=1
999 NEXT
1919 PRINTsFRINT DONE"
1928 IF E=9 THEN PRINT"O.K."sPRINT W$:GOTO 299d
193d PRINT NO GOOD" SPRINT WE:GOTO 29989
1159 INFUT"NAME OF TAPE FILE" INS
114d GOSUB 1499:FRINT’PRESS “PLAY”,"
11798 PRINT’ THEN PRESS ANY KEY."
1188 RS=INKEYSsIF R#="" THEN 11382
1185 PRINT’ SEARCHING FOR "INS
1199 INFUTHN ROSTF RSLENS THEN PRINT RS$:GOTO 1199
1299 PRINTSFRINT FOUND "SNSEFRINT
1216 INPUTHN, RS SK=VAL CRS) SIF Kd THEN 1434
1229 IF Ke=| THEN 7250 ELSE PRINT ES
1238 PRINT'FILE HAS’ SKS "CARIIS. FROGRAM LIMITED TO" SL
1246 GOTO 29699
1259 FOR J=1 TO K
FLASHCARD 75
MAIN ROUTINES
MAIN VARIABLES
SUGGESTED PROJECTS
PURPOSE
HOW TO USE IT
The first thing the program does is ask you how many
questions you would like to do for the session. Any value of
one or higher is acceptable.
The sample run shows how each question is formulated. A
quantity in English units is compared with one in metric units.
Fither one may appear first in the question. Each quantity will
have an integral value. The relating word (“longer,” “hotter,”
80 BASIC Programs for the TRS-80
SAMPLE RUN
A METRIC QUIZ
HOW MANY QUESTIONS SHALL WE DO? 3
QUESTION 1 OF 3
IS 48 MILES LONGER THAN
92 KILOMETERS ? C''N' key pressed)
YOU SAY 'NO' AND YOU'RE RIGHT - VERY GOOD!
QUESTION 2 OF 3
IS 73 DEGREES FAHRENHEIT HOTTER THAN
22 DEGREES CENTIGRADE ? C'"Y'" key pressed)
YOU SAY 'YES' AND YOU'RE RIGHT - VERY GOOD!
#4XXX HIT ANY KEY TO CONTINUE *#%
QUESTION 3 OF 3
IS 79 KILOGRAMS HEAVIER THAN
152 POUNDS ? C'N' key pressed)
YOU SAY 'NO' BUT YOU'RE WRONG
METRIC 81
79 KILOGRAMS EQUALS
174.166 POUNDS
---- THE RULE IS ----
1 KILOGRAM EQUALS
2.28463 POUNDS
ae HIT ANY KEY TO CONTINUE “8%
YOU GOT 2 RIGHT OUT OF 3 QUESTIONS
PERCENTAGE CORRECT = 66.6667
PROGRAM LISTING
EASY CHANGES
MAIN ROUTINES
MAIN VARIABLES
SUGGESTED PROJECTS
PURPOSE
HOW TO USE IT
SAMPLE RUN
bE ao)
ea
28
ai ee oto oe
The program asks what number comes after 7, and waits for a response.
The operator says ‘’8’’, and the program acknowledges that the answer is
correct.
NUMBERS 89
Because of the correct response, the program draws three geometric figures.
PROGRAM LISTING
639
899 FOR J=1 TO 260@:NEXT
819 CLS:PRINT CHR$(23)
829 GOTO 179
EASY CHANGES
MAIN ROUTINES
MAIN VARIABLES
SUGGESTED PROJECTS
PURPOSE
HOW TO USE IT
SAMPLE RUN
Pee MC OLB aM
IM Re C eC ga 2
Ue aaa 2 oe
The program clears the screen and displays two parallel lines in the upper
left corner of the screen for a couple of seconds.
The program flashes a short phrase (chosen at random) between the two
lines for a fraction of a second, then clears the screen.
96 BASIC Programs for the TRS-80
Te oe Oe
? THE BABY CRIED
Meal
SSE Mm
DR ae
The program asks what the phrase was. The operator responds correctly.
The program acknowledges the correct response, and indicates that the
next phrase will be shown for half as long.
PROGRAM LISTING
319 PRINT
329 PRINT'I’LL BRIEFLY DISPLAY A SHORT PHRASE,"
338 PRINT'AND YOU TRY TO READ IT."
549 PRINT
559 PRINT" TYPE WHAT YOU SEE, AND I’LL TELL YoU"
349 PRINT'IF YOU WERE RIGHT."
379 PRINT
419 PRINT"PRESS ANY KEY WHEN YOU’RE READY."
429 RS=INKEY$:IF R$="" THEN 420
439 R=RND(C)
449 IF R=P1 OR R=P2 OR R=P3 THEN 439
459 IF R=P4 OR R=P5 THEN 439
Abd GOSUB 849:FOR K=1 TO 15@@:NEXT
479 PRINT@64,7$(R)3
A489 FOR J=1 TO TsNEXT
JOO CLS:FOR K=1 TO 5@O:NEXT
y19 PRINT :PRINT PRINT :PRINT
wow PRINT'WHAT WAS IT?"
358 INPUT R$
WO IF R$<>T$(R) THEN 799
369 PRINT" THAT’S RIGHT!"
JY T=1/2
39D R$="FOR HALF AS LONG.”
699 P1=P2:P2=P3:P3=P4:P4=P52P5=R
4619 PRINT
6298 IF T<=4 THEN T=4:R¢="AT MAXIMUM SPEED."
639 PRINT" THE NEXT ONE WILL BE DISPLAYED "sR$
549 PRINT:GOTO 419
789 PRINT'NO, THAT’S NOT IT. IT WAS"
718 PRINT'“":T#(R) "7"
729 T=T#2
738 IF 1>169@ THEN T=160G:R%="AT THE SAME SPEED.":
GOTO 639
74D R$="FOR TWICE AS LONG."sGOTO 699
849 CLS:PRINT STRING$(12,"~")
8598 PRINT
849 PRINT STRING$(12,"-")
879 RETURN
919 DATA"AT THE TIME"
929 DATA" THE BROWN COW"
939 DATA"LOOK AT THAT"
949 DATA" IN THE HOUSE"
93598 TATA" THIS IS MINE”
949 DATA"SHE SAID SO”
979 DATA" THE BABY CRIED"
98 BASIC Programs for the TRS-80
EASY CHANGES
MAIN ROUTINES
MAIN VARIABLES
SUGGESTED PROJECTS
PURPOSE
Did you ever find yourself at a loss for words? Well, this vo-
cabulary quiz can be used in a Self-teaching environment or as
reinforcement for classroom instruction to improve your ability
to remember the jargon of any subject. It allows you to drill at
your own pace, without the worry of ridicule from other
students or judgment by an instructor. When you make mistakes,
only the computer knows, and it’s not telling anyone except
you. Modifying the program to substitute a different vocabulary
list is very simple, so you can accumulate many different
versions of this program, each with a different set of words.
HOW TO USE IT
Finally, after the last question, you are shown the percentage
you got correct, along with a comment on your performance.
Then you have the option of going back for another round of
questions or stopping.
SAMPLE RUN
( ... later)
YOU HAVE 3 RIGHT OUT OF 5 QUESTIONS.
THAT'S 69% PERCENT.
NOT BAD, BUT ROOM FOR IMPROVEMENT.
WANT TO TRY AGAIN? NO
PROGRAM LISTING
2nd Q1=9
23588 RETURN
3899 FOR J=1 TOC
3819 PC J)=9
3929 NEXT
3938 FOR J=1 TOC
5849 P=RND(D)
5845 IF P=P1 OR P=F2 OR P=P3 THEN 3949
5959 FOR K=1 TO J
59469 IF P(K)=P THEN 384¢
38/72 NEXT K
3989 P¢J)=P
3899 NEXT J
3119 A=RNDC(C)
32BO RETURN
49BD PRINT
4919 M=RND(2)
4G2G IF M=2 THEN 4199
4G 39 PRINT Q;"-- WHAT WORDT MEANS "SES(P(A))
5" ?"
ADAG FOR J=1 TOC
4959 PRINT TABCS)5 J5%-- USDSCP CJ) )
ADSD NEXT
4979 GOTO 4219
4199 PRINT Q3"-- WHAT DOES "sn$(P(A))3" MEAN?"
4119 FOR J=1 TO €
4129 PRINT TARCS)su2"-- "SES(PCJ))
413d NEXT
4218 RETURN
JOG INPUT R
JO18 IF Re=1 AND R“=C THEN 5059
IG29 PRINT’I NEED A NUMBER FROM 1 TO"SC
1838 GOTO 54a
IIIO IF R=A THEN 5199
0469 PRINT'NO, THE ANSWER IS NUMBER"SA
38." GOTO 5219
3199 PRINT’ RIGHT!"
3119 Q1=Q141
J218 IF Ql=1 THEN 5399
228 PRINT" YOU HAVE" 3Q1s"RIGHT QUT OF :Q:" QUESTIONS."
3388 P3=P2
518 FDssfy
ISO P1=F (A)
Jo5K RETURN
5890 Q=Q+1
4919 IF Q<=l THEN RETURN
VOCAB 105
6929 E=1
6939 Q=Q1+199/(Q-1)
5949 IF Q>6 THEN 4979
6959 PRINT"WELIL, THAT“S A “PERFECT” SCORE..."
6949 GOTO 6299
49/79 PRINT’ THAT“S"5Q3;"PERCENT."
4989 IF Q225 THEN 6119
4999 PRINT"CONGRATULATIONS ON AVOIDING A SHUTOUT."
6198 GOTO 6298
6119 IF Q259 THEN 6149
6129 PRINT"YOU CAN USE SOME MORE PRACTICE."
6136 GOTO 6299
5149 IF Q375 THEN 6179
6159 PRINT"NOT BAD, RUT ROOM FOR IMPROVEMENT."
5169 GOTO 6289
6179 PRINT"VERY GOOD!"
4189 IF Q>95 THEN PRINT" YOU“RE ALMOST AS SMART AS I ANI"
62989 PRINT
6218 INPUT"WANT TO TRY AGAIN’; R$
62298 IF LEFTS(R$,1)<2"N" THEN 62498
6239 PRINT:PRINT"CHECK YOU LATER." :PRINTSEND
4246 IF LEFTS¢(R$,1)<2"Y" THEN 6219
6259 RETURN
FOOD REM: ON LINE 2026, I! MUST BE AT LEAST ONE GREATER
7883 REM: THAN THE NUMBER OF DIFFERENT WORDS.
7919 DATA ANONYMOUS, "OF UNKNOWN OR HIDDEN ORIGIN"
7929 DATA OMINOUS, "THREATENING OR MENACING"
7839 DATA AFFLUENT, "WEALTHY"
7949 DATA APATHETIC, "INDIFFERENT OR UNINTERESTED"
PBIB DATA LACONIC,""TERSE"
7868 DATA INTREPID, "FEARLESS OR COURAGEOUS"
79/8 DATA GREGARIOUS, "SOCTAL OR COMPANY-LOVING"
7888 DATA ENERVATED, "WEAK OR EXHAUSTED"
7899 DATA VENERABLE, "WORTHY OF RESPECT OR REVERENCE"
71898 DATA DISPARATE, "DIFFERENT AND DISTINCT”
7118 DATA VIVACIOUS, "LIVELY OR SPIRITED"
7128 DATA ASTUTE,"KEEN IN JUDGMENT”
71398 DATA URSINE, "BEARLIKE"
7149 DATA PARSINONIOUS,"STINGY OR FRUGAL"
P1AS9 DATA OMNISCIENT,"ALL-KNOWING”
F999 DATA XXX
106 BASIC Programs for the TRS-80
EASY CHANGES
MAIN ROUTINES
MAIN VARIABLES
SUGGESTED PROJECTS
PURPOSE
HOW TO USE IT
digits in your guess that were correct—the digit was correct and
in the correct position. So, if the secret code is 6153 and your
guess is 4143, you will be told that black is 2 (because the 1 and
the 3 will have been correct). Of course, you aren’t told which
digits are correct. That is for you to figure out by making use of
the information you get from other guesses.
Each of the white numbers indicates a digit in your guess that
was correct, but which is in the wrong position. For example,
if the secret code is 6153 and your guess is 1434, you will be
told that white is 2. The | and 3 are correct, but in wrong
positions.
The white number is determined by ignoring any digits that
accounted for a black number. Also, a single position in the
secret code or guess can only account for one black or white
number. These facts become significant when the secret code
and/or your guess have duplicate digits. For example, if the
code is 1234 and your guess is 4444, there is only one black,
and no whites. If the code is 2244 and your guess is 4122, there
are no blacks and three whites.
This may sound a little tricky, but you will quickly get the
hang of it.
At any time during the game, you can ask for a “SUMMARY”
by entering an S instead of a guess. This causes the program to
clear the screen and display each guess (with the corresponding
result) that has occurred so far.
Also, if you get tired of trying and want to give up, you can
enter a Q (for ‘“‘quit’’) to end your misery and find out the
answer. Otherwise, you continue guessing until you get the code
right (four black, zero white), or until you have used up the
maximum of twelve guesses.
SAMPLE RUN
DECODE
a hl
EM (sa! a sg
IN THE RIGHT POSITION.
*VHITE? INDICATES SOME OTHER CORRECT BIGIT
BUT IN THE WRONG POSITION.
The program displays an introduction, chooses its secret code, and asks for
the operator’s first guess. After the operator makes a guess, the program
responds with a “‘black’’ and a ‘‘white’’ number, and asks for the second
guess.
Later in the same game, the operator asks for a summary, then makes the
guess that turns out to be correct. The program acknowledges that the
guess is correct and asks about trying another game.
114 BASIC Programs for the TRS-80
PROGRAM LISTING
EASY CHANGES
MAIN ROUTINES
MAIN VARIABLES
SUGGESTED PROJECTS
PURPOSE
HOW TO USE IT
The game uses two dice. They are just like regular six-sided
dice except for one thing. The die face where the ‘‘1’’ would
normally be has a picture of a frowning face instead. The other
five faces of each die have the usual numbers two through six
on them.
The object is to be the first player to achieve a score agreed
upon before the start of the game. Players alternate taking turns.
A turn consists of a series of dice rolls (at least one roll, possibly
several) subject to the following rules.
As long as no frown appears on either die, the roller builds a
running score for this current series of rolls. After each roll with
no frown, he has the choice of rolling again or passing the dice
to his opponent. If he passes the dice, his score achieved on the
current series is added to any previous total he may have had.
120 BASIC Programs for the TRS-80
SAMPLE RUN
GROAN 121
GROAN
Pept
p ssa Re
CBETIEEN
58-108 1S BEST) ? 58
LET’S TOSS FOR FIRST ROLL
The operator has decided to challenge the TRS-80 to a fifty point game of
GROAN. The computer wins the coin toss and gets the first dice roll.
--SCOREBOARD--
UCR BL 3]
BEFORE THIS SERIES
The computer's roll, however, results in a “groan” and a four. This scores
no points and the dice pass to the operator.
122 BASIC Programs
for the TRS-80
cae a ee
POINTS SCORED yu
pat ae epeedala (rs)
pli Se aU Gi 13)
Much later in the same game, the operator rolls a 12 to start a series of rolls.
The score was operator-29, TRS-80-20 before the roll. The operator must
now decide whether to pass the dice or risk rolling again.
PROGRAM LISTING
EASY CHANGES
1. If you wish to set the program for a fixed value of the winning
score, it can be done by changing line 210 and deleting line
220. Simply set W to the winning score desired. For example:
GROAN 125
210 W=100
would make the winning score 100. Don’t forget to delete
line 220.
. The rolling dice graphics display before each roll can be elimi-
nated by changing lines 500 and 540 as follows:
500 D=266: RI=RND(6):R2=RND(6):GOTO 540
540 C=D+48:GOSUB 650: C=C+384:GOSUB 650
This has the effect of speeding up the game by showing each
dice roll immediately.
. After you play the game a few times, you may wish to change
the delay constants in lines 830 and 840. They control the
“pacing” of the game; i.e., the time delays between various
messages, etc. To speed up the game try
830 FOR K=1 TO 400: NEXT: RETURN
840 FOR K=1 TO 1000: NEXT:RETURN
Of course, if desired, the constants can be set to larger values
to slow down the pacing.
MAIN ROUTINES
MAIN VARIABLES
SUGGESTED PROJECTS
PURPOSE
HOW TO USE IT
right) means the TRS-80 has just guessed your word correctly—
a truly humbling experience. The numerical replies indicate that
the word guessed by the TRS-80 had that number of hits in your
secret word. A response of 3 means that all the letters were cor-
rect, but they need to be rearranged to form the actual secret
word (e.g. a guess of ““EAT”’ with the secret word being ““TEA’’).
After learning how it did, the computer will take some time
to process its new information. If this time is not trivial, the
TRS-80 will display the message: “I’M THINKING” so you do
not suspect it of idle daydreaming. If it finds an inconsistency
in its information, it will ask you for your secret word and then
analyze what went wrong.
When it is your turn to guess, there are two special replies
you can make. These are the single letters S or Q. The S, for
summary, will display a table of all previous guesses and corre-
sponding hits. This is useful as a concise look at all available
information. It will then prompt you again for your next guess.
The Q, for quit, will simply terminate the game.
When not making one of these special replies, you will input
a guess at the computer’s secret word. This will be, of course, a
three letter word. If the word used is not legal, the computer
will so inform you. After a legal guess, you will be told how
many hits your guess had. If you correctly guess the computer’s
word, you will be duly congratulated. The TRS-80 will then ask
you for your secret word and verify that all is on the ‘‘up and
up.
99
SAMPLE RUN
JOT
JUST A MOMENT PLEASE .....
THANKS, NOW LET'S EACH THINK
OF OUR SECRET WORD
CTHIS TAKES ME A WHILE ...)
MY GUESS IS -- NIP
HOW DID I DO Cg-3 OR RD? 1
JOT 129
I'M THINKING
MY GUESS IS -- NOR
HOW DID I DO Cf-3 OR RD? G
I'M THINKING
MY GUESS IS -- PET
HOW DID I DO Cf-3 OR RI? R
PROGRAM LISTING
108 REM: JOT
118 REM: COPYRIGHT 192° BY PHIL FELUMAN ANG TOM RUGG
128 CLEAR 2A@GsTEF INT A-2sRANTION
148 Meat n= 404
178 DTM ACN)
130 BASIC Programs for the TRS-80
“wd
ni
EASY CHANGES
3. Modifying the data list of legal words is fairly easy. Our cri-
teria for legal words was as follows: they must have three
distinct letters and not be
— capitalized
— abbreviations
— interjections (like ‘“‘ugh’’, ““hey”’ etc.)
— specialized words (like “‘ohm’’, 9 “‘sac’’, > “yaw” etc.)
In line 160, N is set to be the total number of words in the
data list. The data list itself is from line 5000 on.
To add word(s), do the following. Enter them in data state-
ments after the current data (use line numbers larger than
5570). Then redefine the value of N to be 406 plus the number
of new words added. For example, to add the words ‘‘ohm”’ and
‘‘vaw’’ onto the list, change line 160 to read
160 M=25:N=408
and add a new line
5580 DATA OHM, YAW
To word(s), the opposite must be done. Remove the
delete
words the appropriate data statement(s) and decrease
from
the value of N accordingly.
MAIN ROUTINES
MAIN VARIABLES
SUGGESTED PROJECTS
PURPOSE
This program allows you and a friend (or enemy) to play the
game of OBSTACLE, an arcade-like game that’s one of our
favorites. A combination of physical skills (reflex speed, hand
to eye coordination, etc.) and strategic skills are needed to beat
your opponent. Each game generally takes only a minute or
two, so you'll want to play a match of several games to deter-
mine the better player.
HOW TO USE IT
The first time either player bumps into the wall surrounding
the playing field or the obstacle wall built by either player, he
loses. When this happens, the program indicates the point of
impact for a few seconds and displays the name of the winner.
Then the game starts over.
The strategic considerations for this game are interesting.
Should you attack your opponent, trying to build a wall around
him that he must crash into? Or should you stay away from him
and try to make efficient moves in an open area until your
opponent runs out of room on his own? Try both approaches
and see which yields the most success.
When pressing a key to change direction, be sure to press it
quickly and release it. Do not hold a key down—you might
inhibit the computer from recognizing a move your opponent
is trying to make. Once in a while, only one key will be recog-
nized when two are hit at once.
SAMPLE RUN
Ht og
The program starts off by asking for the names of the two players.
OBSTACLE 139
tf neg
occe mam Ca
= bi
The program redraws the playing field and starts both players moving in a
random direction (in this case, both start moving to the left). Phil (on the
right) doesn’t change directions soon enough and crashes into the wall,
making Tom the winner.
140 BASIC Programs for the TRS-80
PROGRAM LISTING
1. To speed the game up, change the 8 in line 260 toa 5 or so.
To slow it down, make it 12 or 15.
2. To make both players always start moving upward at the
beginning of each game (instead of in a random direction),
insert the following statement:
168 AD=1:BD=1
To make the players always start off moving toward each
other, use this statement instead:
MAIN ROUTINES
210 - 250 Makes move for player A (on left side) and B (on
right). Saves results.
260 - 350 Accepts moves from keyboard and translates
direction.
400 - 490 Displays winner’s name at bottom of screen.
Flashes a square where collision occurred. Goes
back to start next game.
600 - 630 Subroutine that gets each player’s name.
700 - 750 Subroutine that displays winner’s name.
900 Subroutine that displays each graphics character
of each player’s obstacle on the screen.
950- 990 Subroutine that displays playing field.
1000- 1060 Subroutine that moves marker and determines
if space moved to is empty.
MAIN VARIABLES
SUGGESTED PROJECTS
1. Keep score over a seven game (or so) match. Display the cur-
rent score after each game. Don’t forget to allow for ties.
2. Modify the program to let each player press only two keys—
one to turn left from the current direction of travel, and one
to turn right.
OBSTACLE 143
PURPOSE
HOW TO USE IT
goes on, the race begins. The road moves continually up the
screen. Its twists and turns are controlled randomly. You must
steer the car accurately to keep it on track.
The car is controlled with the use of two keys on the key-
board. Pressing the comma (,) will cause the car to move to the
left while pressing the period (.) will cause a move to the right.
On these keys are the helpful symbols, < and >, respectively.
Doing neither will cause the car to continue straight down.
The race proceeds until the car goes “‘off the road.” Each
such collision is considered to terminate one day of the race.
After each day, you are shown the number of miles achieved
that day along with the cumulative miles achieved for consecu-
tive days of the race.
After each collision, you can proceed by pressing either C, R,
or Q. Selecting C will continue the race for another day with
the same road conditions. Cumulative totals will be retained. R
will restart the race. This allows changing the road conditions
and initializing back to day one. Q simply quits the race and
returns the TRS-80 back to direct Basic. Either of the last two
options will produce a display of the average miles travelled
per day for the race.
There are several different ways to challenge yourself with
the program. You can try to see how far you get in a given num-
ber of days. You might see how many days it takes you to goa
given number of miles—say 3000 miles for a cross-country trip.
As you become proficient at one set of road conditions, make
the road narrower and/or the visibility poorer. This will increase
the challenge. Different road conditions can also be used as a
handicapping aid for two unequally matched opponents.
SAMPLE RUN
ROADRACE 147
The program displays its logo and begins the short input phase. The opera-
tor selects to run a course with a 6 character road width.
ci aCe tea)
VISIBILITY (1-4)? 3.
The operator selects fair visibility and the race is ready to begin.
BASIC Programs for the TRS-80
The car is on the startingline. The starting light counts down the beginning
of the race. When the last light goes on, the race will be off and running.
iSieaeerha bg
esi 1a td
"Y - WIT
The operator, steering the car from the keyboard, finally crashes. A dis-
tance of 110 miles is obtained on this leg for a total of 315 miles in 3 days
(legs). The options for continuing are displayed while the program waits
for the operator’s choice.
ROADRACE 149
PROGRAM LISTING
wo END
699 PRINT TAB(L) SRS$;TAB(R) SLS$
619 RETURN
629 PRINT TAB(L) SLT$;TAB(R-1)sLT$
639 L=L-1:R=R-1sRETURN
649 PRINT TAB(L+1)SRT$3TAB(R) RTS
459 L=L+1:R=R+1 RETURN
709 P=Z+C:GOSUB 959:P=Z+C-15349-26
719 Q$=CHR$ (191) +CHR$(B)+"0"+CHRS(B)
+CHRS$ (191)
729 P=P-32G:PRINT @ P,STRINGS(5,176)3
739 FOR J=1 TO SsP=P+64:PRINT @ P,Q$5:NEXT
74D PRINT @ P+64,STRING$(5, 131):
70 FOR J=1 TO 6@@:NEXT
769 FOR J=4 TO @ STEP -1:FOR K=1 TO 3@0:NEXT
779 PRINT @ P+2-64#*J,CHR$(143)5:NEXT:PRINT @896,CHR$(B)
789 RETURN
889 DIM D(9)sL=18:R=28:CLS
819 FOR J=1 TO 9:READ D(J) sNEXT
829 DATA 82,79,65,48,82,65,67,69,32
839 GOSUB 499
B49 GOSUB 449
859 FOR J=1 TO 2:GOSUB 42@:NEXT
849 FOR J=1 TO 16:GOSUB 649:NEXT
879 P=15383:POKE P,C1:POKE P+1,C2
889 FOR J=1 TO S80:NEXT
899 P=P+65:GOSUB 958
999 FOR J=1 TO 2:P=P+63:GOSUB 950:NEXT
919 P=P+45:GOSUB 959
929 FOR J=1 TO 9:P=P+465:GOSUB 959
939 POKE P,D(J):POKE P+1,BsNEXT
959 POKE P,C1:POKE P+1,C2:FOR K=1 TO 5@:NEXTRETURN
EASY CHANGES
1. The keys which cause the car to move left and right can be
easily changed. You may wish to do this if you are left-
handed or find that two widely separated keys would be
more convenient. The changes are to be made in line 150.
Left and right movements are controlled by the two string
variables L$ and RS. If, for example, you wanted 1 to cause
a left move and 9 to cause a right move, change line 150 to
read
150 L$=*1":R$="9”
ROADRACE 151
MAIN ROUTINES
MAIN VARIABLES
Road width.
moi2zs<=
Visibility.
Miles driven on current day.
Number of days of the race.
Total miles driven for whole race.
Elapsed time during race.
L$,R$ String characters to move car left, right.
L,R Position of left, right side of road.
LC,RC Random value cutoff to move road left, right.
EL,ER Leftmost, rightmost allowable road _ position.
Q$ User replies.
C Position of car.
Z,ZC,ZP POKE arguments for car location.
RS$,LS$ Strings to display road segments.
LT$,RT$
B Blank character value.
Pp Printing position.
D Array of POKE arguments for display message.
152 BASIC Programs for the TRS-80
SUGGESTED PROJECTS
PURPOSE
Wari is an old game with roots that are even older. Its origins
go back thousands of years to a variety of other similar games,
all classified as being members of the Mancala family. Other
variations are Awari, Oware, Pallanguli, Kalah, and countless
other offshoots.
The program matches you against the computer. You are
probably going to lose a few games before you win one—the
computer plays a pretty good game. This may hurt your ego a
little bit, since Wari is purely askill game (like chess or checkers).
There is no element of luck involved, as would be the case with
backgammon, for example. When you lose, it’s because you
were outplayed.
HOW TO USE IT
When you start the program, the first thing it does is display
the Wari board and ask you if you want to go first. The board
is made up of twelve squares in two rows of six. Your side is
the bottom side, numbered one through six from left to right.
The computer's side is on the top, numbered seven through
twelve from right to left.
At the start of the game, each square has four ‘“‘stones”’ in it.
There is no way to differentiate between your stones and the
computer’s. They all look alike and will move from one side to
the other during the course of play.
The first player “picks up”’ all the stones in one of the squares
on his side of the board and drops them, one to a square, starting
154 BASIC Programs for the TRS-80
SAMPLE RUN
ret
i ua
2 Wm @ 9 8 ts
1 2 3 4 3 6
yw
WANT TO GD FIRST?
YES_
The program starts off by drawing the playing ‘‘board’’ and asking who
should move first. The operator decides to go first.
Trai
Ci alia. 4
i 1} re Re 7
1 2 3 4 $5 6
yu
bita ade)
i
1) 4. Saaee
The program asks for the operator’s move. He or she decides to move
square number 5. The program alters the board accordingly, and begins
“thinking’’ about what move to make.
156 BASIC Programs for the TRS-80
ial
i 2 3 4 3 6
Later is the same game, the computer is about to move square number 11,
which will capture four more stones and win the game.
PROGRAM LISTING
MAIN ROUTINES
MAIN VARIABLES
SUGGESTED PROJECTS
PURPOSE
HOW TO USE IT
There is not much to say about how to use this one. Just
type RUN, then sit back and watch. Turning down the lights
and playing a little music is a good way to add to the effect.
By the way, it is a little misleading to say that the designs
you see are symmetrical. It is more accurate to say that the
positions occupied by the individual graphics characters are
located symmetrically. The overall design is usually not com-
pletely symmetrical, since the individual graphics characters are
not themselves symmetrical. The characters on the lower half of
the design would have to be the upside-down equivalent of the
corresponding characters on the upper half for that to be true.
Have a few friends bring their TRS-80s over (all your friends
do have TRS-80s, don’t they?), and get them all going with
KALEIDO at once. Let us know if you think you have set a
new world’s record. Please note that we will not be responsible
for any hypnotic trances induced this way.
166 BASIC Programs
for the TRS-80
SAMPLE RUN
PROGRAM LISTING
198 REM: KALEIDOSCOPE
118 REM: COPYRIGHT 1979 BY TOM RUGG AND PHIL FELIMAN
129 CLEAR S@:RANDOMSCLS:DEFINT A-Z
139 A=477 :T=~1
135 W=42S=7 sL=64 sM2=22:G=169
149 DIM R$(S)
159 FOR J=9 TO SsA$=""sFOR K=1 TO W
169 AS=AS+CHRS (RNU(M)+G) sNEXT
179 R$(J)=A$ sNEXT
189 D=-D
199 P=9:Q=S:IF D048 THEN Q=9:P=S
289 FOR K=P TO @ STEP 0
219 FOR J=K TO Q STEP D
229 PRINT@A+J#U+K#L ROCK) 5 SPRINT@GATK#U+J#L RS (K) 5
2398 PRINT@A+J#U-K#L ROCK) 5 SPRINT@ATK#W-J#L yRSCK) 5
248 PRINT@A~J#W+K#L ,RE(K) 5 sPRINT@A-K#U+ JL »RS(K) 5
258 PRINT@A-J#W-K#L RS (CK) 5 sSPRINT@A-K#W-J#L RSCK) |
268 NEXT sNEXT
388 GOTO 159
KALEIDO 167
EASY CHANGES
1. To clear the screen before the next pattern about 20% of the
time (chosen at random), insert this:
175 IF RND(100)<=20 THEN CLS
For 50%, use 50 instead of 20, etc.
2.To randomly select either a square or rectangular pattern,
insert:
176 W=RND(2)+2
To always get a square pattern, use this instead:
176 W=3
3. To randomly change the size of the patterns, insert:
177 S=RND(4)+3
4. To cause only the outward patterns to be displayed, change
line 180 to say |
180 D=1
To cause only inward patterns, change it to say
180 D=-1
5. To alter the intricacy of the graphics characters used in the
patterns, alter the values of M and Gin line 135. Be sure both
are positive integers, that G is at least 127, and that the sum
of M and G does not exceed 191. For example, try M=64 and
G=127. Or, try M=16 and G=127. Or, M=4 and G=187.
6. To lengthen the delay after each pattern is drawn, insert this
line:
270 FOR J=1 TO 3000:NEXT
Use a number larger than 3000 to increase the length of the
delay even more.
Note: These changes add a lot of the appeal of the designs. Ex-
periment! Each change can be done by itself or in combination
with other changes.
MAIN ROUTINES
MAIN VARIABLES
PURPOSE
HOW TO USE IT
SAMPLE RUN
A UNA, bli Py
mane
™ Wy
Wa aged
SO ho eT
THY Se
Peery
eye
PROGRAM LISTING
188 REM: SPARKLE
119 REM: COPYRIGHT 1979 BY TOM RUGG AND PHIL FELDMAN
128 CLEAR S@sRANDIOMSCLS:REFINT A-Z
136 DIM AC?),B(7) 2A=19sB=7 sS=G
149 T=RND (49) +139
159 FOR J#@ TO 7sA(J)=J2B( Js JsNEXT
1469 FOR J=@ TO 7sR=RND(8)-12WeAC J) sAC J =A(R)
178 ACR) =WUsNEXT
188 FOR J=8 TO 7:R=RNDIM8)-12W=B(J)2B(J)=B(R)
199 B(R)=WeNEXT
299 FOR J=@ TO 7sFOR K=@ TO 7?
21g R=A (J) sW=BCK) sC=R+W+T
246 X=A+RsY=BtWsGOSUB 99¢
259 Y=E-W:GOSUB 99¢
269 X=A-R:GOSUB 998
279 Y=B+W:GOSUB 999
289 X=A+W2Y=B+RsGOSUB 999
299 Y=B-RsGOSUB 989
399 X=A-W:GOSUB 999
318 Y=B+K:GOSUB 996
SPARKLE 171
EASY CHANGES
MAIN ROUTINES
MAIN VARIABLES
SUGGESTED PROJECTS
PURPOSE
HOW TO USE IT
SAMPLE RUN
CETTE
pee
PROGRAM LISTING
EASY CHANGES
MAIN ROUTINES
MAIN VARIABLES
PURPOSE
HOW TO USE IT
Just sit back, relax, and get ready to enjoy the show. Type
RUN and the Flying Walloons will be ready to perform. You
have a front row center seat and the curtain is about to go up.
Applause might be appropriate if you enjoy their performance.
Please note that the Walloons have been working on a big new
finish to their act which they haven’t yet quite perfected.
178 BASIC Programs for the TRS-80
SAMPLE RUN
FLYING
HALLOONS
XK
ae
oe
The Walloons attempt a dangerous trick from their repertoire.
PROGRAM LISTING
EASY CHANGES
MAIN ROUTINES
150 Initializes.
200 - 450 Sets string variables.
470 Introduces the Walloons.
500 - 540 The Walloons make their entrance.
590 - 640 Flying Walloons perform.
700 - 720 Concludes Walloon’s performance.
800 - 810 Displays final message.
900 - 970 Subroutines to draw (and erase) Walloons and
their performing lever.
1200-1260 Subroutine for second Walloon’s entrance.
1300-1390 Subroutine to display placard.
1400-1480 Subroutine to announce the performers.
1700-1800 Time delaying subroutines.
MAIN VARIABLES
A$-Z$ Various graphics strings.
D,E Position increments for graphics displays.
L Location of lever’s left end.
H Location of Walloon’s head.
LJ,K Loop indices.
SUGGESTED PROJECTS
1. There are many possibilities for “‘spicing up’? the Walloons’
act with extra tricks or improved ones. Perhaps you would
like to change their finish to something less crude. To get
you started, here are the changes to produce one alternate
ending:
650 GOTO 730
730 GOSUB 940: H=H—D:GOSUB 910:GOSUB 940
740 PRINT@H,B$:PRINT@H+D,C$:[email protected]$
750 PRINT@H+D, Y$:PRINT@H,C$:PRINT@H,Y$
. If you add some alternate tricks or endings as suggested in
the previous project, try randomizing if and when they will
be done. Thus, the Walloons’ performance will be different
each time the program is run. At least their ending may be
variable.
3. Scour the world yourself for other acts to include in the
TRS-80 Theatre. Maybe someday we will have a complete
software library of performing artists.
Section 5
Mathematics Programs
HOW TO USE IT
The first thing you must do, of course, is enter the data into
the program. This consists of typing in the pairs of numbers.
Fach pair represents an X value and its corresponding Y value.
The two numbers (of each pair) are separated by a comma. A
question mark will prompt you for each data pair. After you
have entered them all, type
999,999
to signal the end of the data. When you do this, the program
will respond by indicating how many data pairs have been
entered. A maximum of 30 data pairs is allowed.
Next, you must input the degree of the polynomial to be
fitted. This can be any non-negative integer subject to certain
constraints. The maximum allowed is 4. Also, D must be less
than the number of data pairs.
A few notes regarding the selection of D may be of interest.
If D=0, the program will output the mean value of Y as the
coefficient Cy. If D=1, the program will be calculating the best
straight line through the data. This special case is known as
‘‘linear regression.’ If D is one less than the number of data
pairs, the program will find an exact fit to the data (barring
round-off and other numerical errors). This is a solution which
passes exactly through each data point.
Once you have entered the desired degree, the program will
begin calculating the results. There will be a pause while this
calculation is performed. The time involved depends on the
number of data pairs and the degree selected. For twenty data
pairs and a second degree fit, the pause will be about fifteen
seconds. Thirty data pairs and a fourth degree fit will take
about forty-five seconds.
The results are displayed in a table. It gives the values of the
coefficients for each power of X from O to D. That is, the values
of Co - Cp) are output. Also shown in the percent goodness of
CURVE 187
= (Y, ¥;)?
P.G.F= 100 * 1 - -
zy, - YP
1
Year Price
1940 $ 8000.
1948 $13000.
195] $16000.
1956 $20000.
1962 $28000.
1968 $39000.
1975 $53000.
The painting is going to be sold at auction in 1979. What price
should the investor expect to have to pay to purchase the
painting? If he resold it in 1983, how much profit should he
expect to make?
Solution: The investor will try to get a polynomial function
that expresses the value of the painting as a function of the year.
This is suitable for CURVE. The year will be represented by the
variable X, and the price is shown by the variable Y. To keep
the magnitude of the numbers small, the years will be expressed
as elapsed years since 1900, and the price will be in units of
$1000. (Thus a year of 40 represents 1940, a price of 8 repre-
sents $8000.)
SAMPLE RUN
46,8
VD
<~<<~<~<~<~<~<-«<
XK
Hom om it wa
Ne
3
oD
ae on
i) Or 100
lw Wit
eo
KK
oD
oO
“Se
NO
oD
‘es
KKK
co
i)
eS
we
LO
YQ
1S)
CO
oO
we
CURVE 189
X,Y=? 75,53
X,Y=? 999,999
7 DATA PAIRS ENTERED
DEGREE OF POLYNOMIAL TO BE FITTED? 1
X POWER COEFFICIENT
p -48.2797
1 1.28724
PERCENT GOODNESS OF FIT= 97.5342
HIT ANY KEY TO CONTINUE
CONTINUATION OPTIONS
1 - DETERMINE SPECIFIC POINTS
2 - FIT ANOTHER DEGREE TO SAME DATA
3 - END PROGRAM
WHAT NEXT? 2
DEGREE OF POLYNOMIAL TO BE FITTED? 2
X POWER COEFFICIENT
g 38.5297
1 -1.83686
2 ~6278514
WHAT NEXT? 1
ENTER 999 TO LEAVE THIS MODE
X=? 79
Y= 62.2451
X=? 83
Y= 72.427
X=? 999
WHAT NEXT? 3.
READY.
190 BASIC Programs for the TRS-80
PROGRAM LISTING
199 REM: CURVE
119 REM: COPYRIGHT 1979 BY FHIL FELDMAN AND TOM RUGG
129 CLEAR 54
149 DEF INT IL.
158 MX=39
149 EF=999
178 MII=4
299 LIM X(MX),Y (MX)
219 Q=MD+1:0IM A(Q,Q),R(Q),V(Q)
229 Q=MEe2 201M PQ)
38d CLS!FRINT” - LEAST SQUARES CURVE FITTING -":PRINT
319 PRINT"ENTER A DATA PAIR IN RESFONSE TO EACH"
329 PRINT'QUESTION MARK. EACH PAIR IS AN X VALUE"
339 PRINT"AND A Y VALUE SEPARATEL BY A COMMA.":PRINT
349 FRINT"AFTER ALL DATA IS ENTERED, TYPE"
359 PRINT EFS", "SEF
3568 PRINT'IN RESPONSE TO THE LAST QUESTION MARK." :PRINT
379 PRINT’ THE PROGRAM IS CURRENTLY SET TO ACCEPT"
389 PRINT’A MAXIMUM OF IMX!"DATA FAIRS."
469 PRINT: J=9
419 J=J41 SINPUT'X, Y=" XCD) YO)
429 TE XQD=EF AND YOSEF THEN J=J-1:G0TO 459
439 IF J=4X THEN PRINT#c® NO MORE DATA ALLOWED set's
GOTO 459
449 GOTO 419
458 NP=JsPRINT
46D IF NF=d
PRINT": FATAL ERROR! a -- NO OATA ENTERED :STOP
4/9 PRINT NPS"DATA FAIRS ENTERED"
CURVE 191
EASY CHANGES
MAIN ROUTINES
MAIN VARIABLES
SUGGESTED PROJECTS
PURPOSE
dY
— = (any function of X,Y)
dx
Here, X is the independent variable and Y is the dependent vari-
able. The equation expresses the derivative (or rate of change)
of Y with respect to X. The right-hand-side is an expression
which may involve X and/or Y.
To use the program, you must supply it with the differential
equation to be solved. The procedure to do this is explained in
the “‘How To Use It”’ section.
A technique known as the “fourth-order, Runge-Kutta”’
method is used to solve the equation. Space limitations prevent
196 BASIC Programs for the TRS-80
HOW TO USE IT
lower left of the screen, telling you the program is waiting for
you to hit any key to begin the output.
The output is displayed at each interval of the stepsize until
the final value of X is reached. Output may temporarily be
halted at any time by simply hitting any key. This will stop the
display until you hit any key to resume the output. The output
may be started and stopped as often as desired, thus enabling
you to leisurely view intermediate results before they scroll off
the screen. It is applicable to both the tabular and graphical
forms of output.
Solution and Sample Run: The solution and sample run are
illustrated in the accompanying photographs.
198 BASIC Programs for the TRS-80
ai we iaaa eC Oe: 2
DEFINED AT LINE 3088. THE FORM IS
Koos lage aaOU a)
Uae
a
ec BC
are OAC
The operator hits a key to exit from the program. Then he enters the
differential equation into line 3000. He types RUN to restart the program.
(Mt 2 dm tgg3 41 Me Us a
Meat eC Mae
INITIAL YALUE OF 2? _
The operator has hit the ‘‘C’’ key. The program responds by beginning the
input phase.
DIFFEON 199
INITIAL VALUE OF X? @
INITIAL VALUE OF Y? @
STEPSIZE IN X? 18
FINAL VALUE OF x? 128
Ud ume ed Gy eae en
i Y
a
The operator has completed the input and requested tabular output. The
program signals with a question mark that it is waiting for him to hit any
key. It will not continue the run until he does so.
HS
8
i)
ra)
38
48
i]
co)
a
88
%
Uy
118
128
bag
ns
f
The operator hits a key and the program responds with the tabulated
output. X is time in seconds and Y is velocity in cm./sec.
200 BASIC Programs
for the TRS-80
x
8
rT)
F)
E
rf)
F)
6a
rt
E
e)
108
1
he
The program is rerun requesting graphical output. Before this photo, the
program requested a minimum and maximum value of Y to use on the Y
axis. Values of 0 and 850 respectively were entered. The program displays
the desired graph.
PROGRAM LISTING
198 REM: DIFFEQN
119 REM: COPYRIGHT 1979 BY PHIL FELDMAN AND TOM RUGG
158 CLEAR 159
209 CLSsFOR J=1 TO 1@sR$=INKEY$=:NEXT
219 PRINT" FIRST ORUER DIFFERENTIAL EQUATION SOLVER"
228 PRINT@197, "THE DIFFERENTIAL EQUATION MUST BE"
2398 PRINT@259, "QEFINED AT LINE 3404. THE FORM IS”
249 PRINT@328, "3908 Di=(YOUR FUNCTION OF X,Y)"
259 PRINT@387, "WHERE D=DY/0X."
268 PRINT@S17,"IF THIS HAS ALREADY BEEN DONE, HIT"
279 PRINT@S79,"THE “C“ KEY TO CONTINUE THE PROGRAM."
289 PRINT@4645,"IF NOT, HIT ANY OTHER KEY. THEN”
298 PRINT@797, "ENTER LINE 3889 AND RE-RUN THE PROGRAM."
399 PRINT@139,STRINGS (41,143) 5 sBS=STRINGS (2,191)
319 FOR J=128 TO 768 STEP 64:PRINT@J, BS; sNEXT
329 PRINT@459,STRINGS(41,149)5:FOR J=171 TO 747 STEP 64
338 [email protected],BS5sNEXT sPRINT@748, STRINGS (45,143)
496 RS=INKEY$:IF R$="" THEN 469
419 IF R$<>"C" THEN END
DIFFEON 201
EASY CHANGES
MAIN ROUTINES
MAIN VARIABLES
D Value of dY/dX.
X, Y Values of X,Y on current step.
XX, YY Values of X,Y on last step.
DX Stepsize in X.
XF Final value of X.
F$ Output flag string (T=table, G=graph).
YL,YH Minimum, maximum values of Y plot axis.
F Fractional distance of graphical point along Y axis.
V Tab position for graphical output.
C CHR$ argument for graphical output.
KO,K1, Runge-Kutta coefficients.
K2,K3
R$ User entered string.
Q Work variable.
J Loop index.
B$,C$ Graphical format strings.
D$,E$
SUGGESTED PROJECTS
PURPOSE
HOW TO USE IT
Before running the program, you must enter into it the func-
tion to be plotted. This is done as a subroutine beginning at line
5000. It must define Y as a function of X. The subroutine will
be called with X set to various values. It must then set the
variable Y to the correct corresponding value. The subroutine
may be as simple or as complex as necessary to define the
function. It can take one line or several hundred lines. Line
5999 is already set as a RETURN statement, so you need not
add another one.
Having entered this subroutine, you are ready to run the pro-
gram. The program begins by warning you that it assumes the
function has already been entered at line 5000. It will then ask
206 BASIC Programs for the TRS-80
you for the domain of X, 1.e. the lowest and highest values of X
that you wish to have plotted. Values can be positive or negative
as longas the highest value is actually larger than the lowest one.
Now you must choose the scale for Y. To do this intelligently,
you probably need to know the minimum and maximum values
of Y over the domain of X selected. The program finds these
values and displays them for you. You must then choose the
minimum and maximum values you wish to have on the Y scale.
Again, any two values are acceptable as long as the maximum
scale value of Y is larger than the minimum scale value of Y.
The program will now display the plot of your function. Each
axis is forty characters long, with the origin defined as the
minimum scale values of both X and Y. Twenty tick marks
appear on each axis. The minimum, middle, and maximum
values on each scale are displayed appropriately.
If a value for Y should be off-scale, an asterisk will be dis-
played at the appropriate value of X. If the actual value of Y is
too large, it will be plotted at the maximum Y value. Similarly,
it will be drawn at the minimum Y value if it is too low.
Some plots have open circles plotted along the X axis. These
correspond to points whose Y values are equal to the value of Y
along the X axis.
After the plot is drawn, the program will tell you to hit any
key to continue. When you do so, information about the plot
scaling is provided. For both X and Y, you are given the mini-
mum, mid, and maximum values on each axis.
You now have the option of hitting G to draw the graph
again or any Other key to terminate the program.
GRAPH 207
SAMPLE RUN
s4 teth
>S5000 Y=SINCX>
>RUN_
After loading the program, the operator enters line 5000 to request the
graph Y=SIN(X). RUN is typed to begin the program.
Tee PORE gy
THE SUBROUTINE AT LINES
5660-5999 IS ASSUMED To
DEFINE Y AS A FUNCTION OF x
LOWEST VALUE OF X? @
HIGHEST VALUE OF 2%? 6.28
The input dialog transpires. The operator asks that the domain of X be
0-6.28. The program responds by showing the maximum and minimum
value of Y over this domain. The operator chooses an appropriate scale for
the Y axis.
208 BASIC Programs for the TRS-80
The graph is displayed as requested. The program waits for the operator to
hit any key to continue.
* SCALING
Paap aye lal
pet)
MAXIMUM
SCALING
POP ae
MID
MAXIMUM
PROGRAM LISTING
EASY CHANGES
1. You may want the program to self-scale the Y axis for you.
That is, you want it to use the minimum and maximum Y
values that it finds as the limits on the Y axis. This can be
accomplished by adding the following line:
835 YU=MX:YL=MN:RETURN
2.Do you sometimes forget to enter the subroutine at line 5000
despite the introductory warning? As is, the program will
plot the straight line Y=O if you do this. If you want a more
drastic reaction to prevent this, change line 5000 to read
5000 Y=1/0
Now, if you don’t enter the actual subroutine desired, the
program will stop and print the following message after you
enter the X scaling values.
?/0 ERROR IN 5000
MAIN ROUTINES
MAIN VARIABLES
SUGGESTED PROJECTS
X—=U
L_ MQW ’vw‘”
SSvV”"
WWWW’W’W’w
y = f(x)
SS
:
Wi
x
Cc
|
HOW TO USE IT
SAMPLE RUN
x=]
‘ d
/ 1+x? *
x=0
5806 Y=4/C14+X*x)
RUN
INTEGRAL BY SIMPSON'S RULE
WARNING!
Y AS A FUNCTION OF X
LOWER LIMIT OF X? §@
UPPER LIMIT OF X? 1
INTEGRATE 217
# SEGMENTS INTEGRAL
2 3.13333
Ly 3.14157
8 3.14159
16 3.14159
32 3.14159
64 3.14159
128 3.14159
PROGRAM LISTING
628 N=N+#2
638 GOTO 499
4979 REM
4988 REM +e ENTER SUBROUTINE AT LINE S900 +t:
4999 REM
JOGO REM etcetek Y=F CX) GOES HERE etctcte
I999 RETURN
EASY CHANGES
MAIN ROUTINES
MAIN VARIABLES
N Number of segments.
J Loop index.
L,U Lower, Upper integration limit of x.
DX Width of one segment.
Partial result of integral.
Number of summations.
Subtotal of summations.
PN
Value of integral.
Current value of x.
Kx
SUGGESTED PROJECTS
PURPOSE
HOW TO USE IT
The program will prompt you for all necessary inputs. First,
it asks how many equations (and thus how many unknowns)
comprise your set. This number must be at least 1. If it is too
large, a OM or BS error will immediately result.
Next, you must enter the coefficients and right-handsides for
each equation. The program will request these one at a time,
continually indicating which term it is expecting next.
Once it has all your inputs, the program begins calculating
the solution. This may take a little while if the value of N is
high. The program ends by displaying the answers. These, of
course, are the values of each of the unknowns, X, through Xx -
If you are interested, the numerical technique used to solve
the equations is known as Gaussian elimination. Row interchange
to achieve pivotal condensation is employed. (This keeps maxi-
mum significance in the numbers.) Then back substitution is
used to arrive at the final results. This technique is much simpler
than it sounds and is described well in the numerical analysis
books referenced in the bibliography.
SAMPLE PROBLEM AND RUN
Problem: A painter has a large supply of three different
colors of paint: dark green, light green, and pure blue. The dark
green is 30% blue pigment, 20% yellow pigment, and the rest
base. The light green is 10% blue pigment, 35% yellow pigment,
and the rest base. The pure blue is 90% blue pigment, no yellow
pigment, and the rest base. The painter, however, needs a me-
dium green to be composed of 25% blue pigment, 25% yellow
pigment, and the rest base. In what percentages should he mix
his three paints to achieve this mixture?
Solution: Let X, = percent of dark green to use,
X, = percent of light green to use,
X, = percent of pure blue to use.
The problem leads to these three simultaneous equations to
Solve:
0.3X, +01 X, +0.9 X, = 0.25
0.2 X, + 0.35X, = 0.25
X, + X, + X, = 1.0
The first equation expresses the amount of blue pigment in the
mixture. The second equation is for the yellow pigment. The
SIMEQN 223
SAMPLE RUN
THE SOLUTION IS
X1= .55
X2= .4
X3= .95
READY.
PROGRAM LISTING
EASY CHANGES
MAIN ROUTINES
MAIN VARIABLES
Array of right-hand-sides.
Array of the solution.
Work variable.
226 BASIC Programs for the TRS-80
SUGGESTED PROJECTS
PURPOSE
HOW TO USE IT
Before entering the data, the program will ask whether or not
you wish to use identifiers with the data values. These identifiers
can be anything associated with the data: e.g. names accom-
228 BASIC Programs for the TRS-80
any key to resume the display. This starting and stopping can be
repeated as often as desired. When the display is completed, you
must again hit a key to re-enter the command mode.
Option 3 produces a statistical analysis of your data. Various
statistical parameters are calculated and displayed. The following
is an explanation of some that may not be familiar to you.
Three measures of location, or central tendency, are provided.
These are indicators-of an “‘average”’ value. The mean is the sum
of the values divided by the number of values. If the values are
arranged in order from highest to lowest, the median is the
middle value if the number of values is odd. If it is even, the
median is the number halfway between the two middle values.
The midrange is the number halfway between the largest and
smallest values.
These measures of location give information about the
average value of the data. However, they give no idea of how
the data is dispersed or spread out around this “‘average.”’ For
that we need ‘“‘measures of dispersion” or as they are sometimes
called, “‘measures of variation.”’ The simplest of these is the
range which is just the difference between the highest and
lowest data values. Two other closely related measures of dis-
persion are given: the variance and the standard deviation. The
variance is defined as:
N
> (V,> M?
_ i=l
VA =
N-1
Here N is the number of values, Vv. is value i, M is the mean
value. The standard deviation is simply the square root of the
variance. We do not have space to detail a lengthy discussion of
their theoretical use. For this refer to the bibliography. Basically,
however, the smaller the standard deviation, the more all the
data tends to be clustered close to the mean value.
One word of warning—the first time option 2 or 3 is selected,
the program must take some time to sort the data into numerical
order. The time this requires depends upon how many items are
on the list and how badly they are out of sequence. Average
times are twenty-five seconds for twenty-five items, almost two
minutes for fifty items, about seven minutes for a hundred
items. The TRS-80 will pause while this is occurring, so don’t
230 BASIC Programs for the TRS-80
SAMPLE RUN
STATS
The program describes its wares. It asks whether or not the operator
wishes to use identifiers with his or her input data. The operator replies
yes.
STATS 231
DATA ITEM # 1
1.0.2 _
VALUE? 76
Cm ae
a eed i
VALUE? 81.5
DATA ITEM # 4
eae
VALUE? 97.5
DATA ITEM #5
Sg
VALUE? 69
DATA ITEM # 6
hee 3,1
The operator completes entering the names and scores of those who took a
programming aptitude test. The actual test was given to many people, but
for demonstration purposes, only five names are used here. The special
string, “END, is used to signal the end of the data.
232 BASIC Programs for the TRS-80
EEE
WHAT NEXT
(ir 2r 3h OR 4)? 2
HEHEHE
CUth et i ag
MG Waa ti at35
The operator requests that the list be sorted into numerical order. The
program first shows the total number of entries.
bhi 1
8
TN}
3)
A)
Cy]
OM mame OC Lg
The operator hits a key to start the display and is then shown the data list
in ranking order. The program waits for the pressing of a key to continue.
STATS 233
WU mam
me eta
Later in the run, the operator selects continuation option 3. This calculates
and displays the various statistical quantities.
PROGRAM LISTING
288 PRINT
299 PRINT" WOULD YOU LIKE TO USE IDENTIFIERS WITH"
58D PRINT’ YOUR INPUT (Y OR N) ? "5
519 R$=INKEY$:IF R$=""" THEN 319
329 IF R#="Y" THEN PRINT’ YES" sF=1:GOTO 488
339 IF R$="N" THEN PRINT’ NO" :F=@:GOTO 4694
3549 GOTO 319
499 FOR J=1 TO 34@:NEXT:GOSUB 2199
419 PRINT" THE DATA MUST NOW BE ENTERED." sPRINT
429 IF F=1 THEN 459
439 PRINT" ENTER EACH VALUE SEPARATELY IN RESPONSE TO"
449 PRINT"THE QUESTION MARK." :GOSUB 2949:GOTO 399
459 PRINT" FOR EACH GATA ITEM, ENTER ITS IDENTIFIER"
4469 PRINT’ (ARBREVIATED I.0.) AND ITS VALUE IN RESPONSE"
4/9 PRINT"TO THE SEPARATE QUESTION MARKS.":sGOSUB 2499
IBD GOSURK 2190sFOR J=1 TO 9sR¢=INKEY$s:NEXTsN=1
31d IF Nit THEN N=1
woe PRINTsSPRINT' DATA ITEM #'5N
338 IF F=8 THEN DS(N)=N$SGOTO 579
JAD INFUT"I.0."SR$:IF R$=E$S THEN 799
JO IF R#=B% THEN N=N-1:G60TO 5192
169 lis (ND SRS
w7@ INPUT" VALUE" SR$:IF R$=ES THEN 700
JOO IF R#=B% AND F=1 THEN 3298
39D IF R$=B$ THEN N=N-1:GOTO 519
599 VIN)=VAL (RS)
619 IF N=MX THEN PRINT ELSE 6392
629 PRINT: NO MORE DATA ALLOWED! +" sN=N+1:sGOTO 74d
439 N=N+1:G0TO Sid
799 N=N~-TsIF N=@ THEN FRINT ELSE 729
719 PRINT':#+ NO DATA -- RUN ABORTED +" s END
726 GOSUR 2194
738 PRINTSPRINT’-- CONTINUATION OF TIONS -~-"'sPRINT
74d PRINT’ 1) LIST DATA IN ORIGINAL ORDER"
PIO PRINT’ 2) LIST DATA IN RANKING ORDER"
7&9 PRINT’ 3) DISPLAY STATISTICS"
778 PRINT" 4) END PROGRAM
789 PRINTsPRINT'WHAT NEXT (1, 2, 3, OR 4) 7 "5
798 R$=INKEY$SsIF R$=""" THEN 799
899 R=VAL(R$) SIF R<1 OR R>4 THEN 799
819 PRINT RsIF R=4 THEN END
829 ON R GOSUR 1949,1289,150¢
838 GOTO 726
1998 GOSUR 219@:FRINT
1919 PRINT” THE ORIGINAL DATA ORDER’ sFRINT
STATS 235
EASY CHANGES
MAIN ROUTINES
MAIN VARIABLES
SUGGESTED PROJECTS
PURPOSE
HOW TO USE IT
SAMPLE RUN
(etc.)
PROGRAM LISTING
199 REM: COINCIDENT BIRTHDAY PROBABILITY PROBLEM
118 REM: COPYRIGHT 1979 BY TOM RUGG AND PHIL FELIMAN
129 CLS
138 PRINT'NO. OF PROB. OF 2 OR MORE"
149 PRINT" PEOPLE WITH SAME BIRTHDAY"
158 Q=1
148 FOR N=1 TO 68
179 PRINT N,1-Q
188 Q=Q:*(365-N)/365
198 NEXT N
298 ENT!
BIRTHDAY 245
EASY CHANGES
MAIN ROUTINES
MAIN VARIABLES
SUGGESTED PROJECTS
-
ond
©
HOW TO USE IT
The program requires only one input from you. This is the
‘“‘sample size for printing,” i.e. how many darts it should throw
before printing its current results. Any value of one or higher
is acceptable.
After you input this number, the program will commence the
simulation and display its results. A cumulative total of “hits,”
darts thrown, and the current approximation to 7 will be dis-
played for each multiple of the sample size.
This will continue until you press the BREAK key. When you
are satisfied with the total number of darts thrown, press the
BREAK key to terminate the program execution.
SAMPLE RUN
A DARTBOARD PI CALCULATOR
A DARTBOARD PI CALCULATOR
# HITS # THROWN PI
PROGRAM LISTING
189 REMs FI
1198REM: COPYRIGHT 1979 BY PHIL FELUMAN AND TOM RUGG
159 RANTIOMECLEAR SM@sUEFINT J
149 T=O2 THe
398 GOSUB 68d
3198TNPUT'SAMPLE SIZE FOR PRINTING" 9 NF
A28 NP INTONPO STF NFAT THEN 3986
338 GOSUB 699
349 PRINTSR HITS # THROWN" 5 TAB( 34) 2"R I"
4G GOSUB 540s TH=THtNHs T= T+NF eh sel H/T
419 PRINT TH. T.F
429 GOTO 484
98 NH=@sFOR J=1 TO NF
“1d KERNTCA) sY=RNGCG)
28 IF (XeX+YY 1 THEN NH=NH+1
3G NEXT sRE TURN
688 CLSOsPRINT TABCS)5
619 PRINT'A TIARTROART PI CALCULATOR"
629 PRINT sRE TURN
251
EASY CHANGES
MAIN ROUTINES
MAIN VARIABLES
SUGGESTED PROJECTS
PURPOSE
HOW TO USE IT
The program first asks you how many digits long you want
the largest number to be. This can be any integer from 1 to 250.
So, for example, if you enter 40, you will get answers up to
forty digits long.
254 BASIC Programs for the TRS-80
Next you are asked for the value of N. If you respond with a
value of 1, you are requesting to be shown all the factorials that
will fit in the number of digits you specified. First you will get
one factorial, then two factorial, and so on. In case you have
forgotten, three factorial is 3 times 2 times 1, or 6. Four fac-
torial is 4 times 3 times 2 times 1, or 24.
If you enter an N in the range from 2 through 100,000, you
are requesting the successive powers of that number up to the
limit of digits you specified. So, if you provide an N of 23, you
will get 23 to the first power, then 23 squared, then 23 cubed,
and so on.
Finally, after it has displayed the largest number that will fit
within the number of digits you entered, the program starts
over. The larger the number of digits you ask for, the longer
it will take the program to calculate each number.
SAMPLE RUN
NUMBER OF DIGITS? 48
LE h2
i 98789
2 Baal asa
3 BU Ck SF
rt ava ha: Jest cS
3 Bet RRS nae)
) Bis SCL NaC RC S|
Fi Sn nae eR abe era
cs Bana SEK eee Sass Ue cl
NUMBER OF DIGITS? _
PROGRAM LISTING
EASY CHANGES
3. If 250 digits isn’t enough for you, you can go higher. For
500 digits, make these changes:
a. In line 160, change the 255 into 505.
b. In line 180, change the 250 into 500.
c. In line 500, change the 255 into 505.
MAIN ROUTINES
MAIN VARIABLES
powers of N.
Set to zero if powers, | if factorials.
QoAAT
SUGGESTED PROJECTS
PURPOSE
HOW TO USE IT
SAMPLE RUN
PROGRAM LISTING
189 REM: PYTHAGOREAN TRIPLETS
119 REM: COPYRIGHT 1979 BY TOM RUGG AND PHIL FELDMAN
129 CLEAR S@:DEFDBL A~Z
139 R=2ek=1s0=9
15d GOSUB 359
188 S=R~-1
198 A=R#*R-S:#5
299 B= 2eRS
219 C=R#R+545
229 PRINT K,A,B,C
2359 K+) sU=0+1:G0TO 489
249 S=$-2:IF S<=@ THEN R=R+1:GOTO 189
209 S1=5
250 B1=R
269 N=INT(B1/S1)
279 R1=B1-(S1#N)
289 IF R1<2@ THEN B1=51:S1=R1:G0TO 249
589 IF S1<>1 THEN 249
329 GOTO 199
3a8 CLS
548 PRINT TAB( 19) 5 "et: PYTHAGOREAN TRIPLETS ‘tte!
PRINT" COUNT" ,"--A--", "=-B-~","--C--"
589
398 RETURN
499 IF D<13 THEN 249
429 PRINT'PRESS ANY KEY TO CONTINUE";
439 IF INKEY$="" THEN 439
449 GOSUB 359
459 D=9
449 GOTO 249
EASY CHANGES
MAIN ROUTINES
MAIN VARIABLES
SUGGESTED PROJECTS
CHECKBOOK
BOOKS
PERIODICALS