A=
694 - 5.37143 *
21
6
96.8667
Lines
118
.
128
The PRINT statements display the resulting trend line equation:
FORECAST FOR PERIOD X
IS
96.86666666666 + 5.3714285714286 * X
Line 110 prints the text contained within the quotes:
"FORECAST FOR PERIOD X
IS"
Line 120 then prints the equation for the predicted sales
in
period
X.
Note the use of
the semicolons
to
keep everything printed immediately adjacent
to
one another. Note
also that the A and B in this statement are not enclosed
in
quotes,
so
that the values
stored in the variables A and B are printed. All other items
in
this statement are
enclosed in quotes and are therefore string constants, which print out
eXflctly
as
specified within the quotes.
Since Line 120
is
the last statement in the program, execution terminates after the
print.
The FOR / NEXT statement pair introduced
in
this lesson is very useful when you
need
to
repeat the same set of procedures a predetermined number of times. Since this
situation comes up regularly in computer programming, you will
no
doubt want
to
use
the FOR / NEXT pair quite often in your own programs.
The following experiments will give you a few more ideas for its application and show
you that the FOR statement offers even more flexibility.
Experiment
#2
Arrays
This experiment will store the sales data
as
part of the Sales Trend program, rather
than ask you
to
input it during execution.
This will make it easier
to
try
several experiments on the data without having
to
retype
it each time the program
is
run.
Change the Sales Trend program
by
entering the following lines:
20
N
=
24
25
DIM
Y(24)
40
50
READ
VeX)
70
BY
=
BY
+
vex)
:XY
=
XY
+
X*Y(X)
200
DATA
160,
175,
140,
230
210
DATA
155,
215,
155,
225
220
DATA
215,
265, 220,
325
230
DATA
225,
270,
265,
280
240
DATA
275,
350,
255,
3a5
250
DATA
300,
330,
315,
380
92