Radio Shack TRS-80 Model 100 Basic Manual page 94

Basic language lab
Hide thumbs Also See for TRS-80 Model 100:
Table of Contents

Advertisement

you have just entered to compute the values of A and B. If you entered the data
exactly as shown above, the program will print:
FORECAST FOR PERIOD X IS
86.86666666666
+
5.371QZ8571QZ86*X
You can now use this formula to predict any future period sales by plugging an
appropriate value for X. For example, to predict period 7 sales, enter the following
from the keyboard:
PRINT 86.8667 + 5.371Q3 * 7
The resulting number, 134.467, represents the trend line forecast of period 7 sales.
You can use the program to calculate the trend line formula for any number of time
periods and any sales data. Try running the program again with your own data. You
can use any convenient time period you wish, such as day, week, month, quarter, or
year.
How the Sales Trend Program Works
Look at the listing of the Sales Trend program and compare it to the flowchart in
Figure 7-1.
Line 18 The CLS statement clears the display.
Line 28 The INPUT statement displays the prompt message "NUMBER OF
PERIODS?" and then waits for data to be entered. The question mark is automatically
added by the INPUT statement and should not be inserted within the quotes of the
prompt message. When
mEID
is pressed, the number which has been typed will be
assigned to the numeric variable N.
Line 38 The FOR statement defines the beginning of a loop which is to be repeated
with successive values for the index variable X. You can think of this statement as
saying:
Perform the following statements with X equal to I. Then repeat the same
statements with X equal to 2. Continue repeating these same statements with
successively incremented values of X (l, 2, 3, etc.). Stop repeating this loop of
statements when X becomes equal to the upper limit N.
Since the variable N is INPUT during execution, this program can be used to compute
a trend line for any number of sales periods.
The end of the loop is determined by a matching NEXT statement (see Line 80).
When the NEXT X statement is encountered, the loop is repeated with the next value
of X. If the upper limit N has been reached, execution continues with the statement
following the NEXT statement.
In general, the FOR statement has an index variable, a start value and a stop value.
The index variable must be a numeric variable. The start and stop values may be
constants, variables or expressions. Another example of a FOR statement would be:
30 FOR A
=
U TO
ZJ(Y-2)
88

Advertisement

Table of Contents
loading

Table of Contents