EasyManua.ls Logo

Radio Shack TRS-80 Model 100

Radio Shack TRS-80 Model 100
210 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Lesson
#7
Sales Trend
In this Lesson, you will learn how to create a program loop with a predetermined
number
of
repetitions. This is a useful technique when combined with subscripted
variables, which will also be introduced in this lesson.
Experiment
#1
Sales Trend
The program below is a "Sales Trend" program. Its purpose is
to
help predict future
sales based upon the trend
of
previous sales. The concept underlining this program is
to
find a straight line which best fits the historical data and then
to
project this line
into the future.
Clear working memory with the NEW command and enter the following program:
10
CLS
20
INPUT
"NUMBER
OF
PERIODS";
N
30
FOR
X
=
1
TO
N
110
PRINT
"SALES
FOR
PERIOO";X;
50
INPUT
Y
60
SX
=
SX
+
X:XX
=
XX
+
X*X
70
SY
=
SY
+
Y:XY
=
XY
+
X*Y
80
NEXT
X
80
B
;;;
(N*XY
-
SX*SY)
/
(N*XX
-
SX*SX)
100
A
;;;
(SY
-
B*SX)
/ N
110
PRINT
"FORECAST
FOR
PERIOD
X IS"
120
PRINT
A;
"
+
II
;
B;
..
*
X"
Execute this program.
The program begins by asking you
to
enter the number
of
periods
of
historical sales
data. Type 6 and press
(ENTER).
The program then prompts you for the sales data for each of the six time periods.
Enter the following sales data:
SALES
FOR
PERIOD
17
103
SALES
FOR
PERIOD
27
110
SALES
FOR
PERIOD
37
108
SALES
FOR
PERIOD
117
120
SALES
FOR
PERIOD
57
118
SALES
FOR
PERIOD
6?
133
The formula for a straight line
is:
Y = A +
B*X
where Y stands for Sales and X for the time period number. A
is
called the
"intercept"
and B the
"slope"
of
the line. The program uses the sales data which
87

Other manuals for Radio Shack TRS-80 Model 100

Related product manuals