Radio Shack TRS-80 Model 100 Basic Manual page 139

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

Advertisement

Day
value of
print position
D
D *5
is column
1
5
6
2
10
11
3
15
16
4
20
21
5
25
26
Examine the output closely by adjusting the Display Control dial until the column
lines become clearly visible. Notice that the first digits of the sales are actually printed
one column to the right of the print position specified by the TAB statement. When a
number is printed, the first position.is reserved for a sign. If the number is positive,
then the plus sign (
+ )
is not printed, but the space is still printed. If the number is
negative, then the minus sign ( - ) is displayed.
Note that the variable S(W,D) is followed by a semicolon. This suppresses the
carriage return so that the next sales amount printed for the week will 'be in the same
line. Since the carriage return was suppressed in the print statement in line 50, the
week' number and daily sales for that week are all displayed on the same line.
Line 89 The NEXT statement defines the end of inner loop which displays the sales
for each day.
The PRINT statement in this line generates a carriage return, which causes the next
week's sales to be displayed on the next line.
Line 99 The NEXT W statement defines the end of the outer loop which causes the
sales for each week to be displayed.
Experiment #2 Compute and Display
the Weekly Average
The previous program will be changed so that the weekly average sales can be
computed and displayed along with the daily sales.
Change line 40 to:
1I0 PR I NT "WEEK MoN TUE WED THU FR I AI)G"
and line 80
80
NEXT
0 :
PRINT WA /
5
Also enter two new lines:
55
WA
=
0
65 WA
=
WA
+
S(W,o)
List the program to confirm that it is:
5
OPEN "RAM:SALEoA.oo" FOR INPUT AS 1
10 FOR W
=
1 TO 6 : FOR 0
=
1 TO 5
20 INPUT
#
1, S(W,O)
30 NEXT 0 : NEXT W
1I0 PRINT "WEEK
MoN
TUE
WED
THU
FRI
AVG"
133

Advertisement

Table of Contents
loading

Table of Contents