This is the solution of Practice Program 3.3

The program file is:

!The text file values.dat, on the current directory

!of the current disk, contains three numbers on separate

!lines. Read these three numbers from the file and display

!the ave value on the screen. Use 3,4,5 so the ave is 4.

!First create value.dat

!Then write the program

!Then run the program

 

OPEN #1: name "values.dat"

LET count = 0

INPUT #1: a

LET count = count+1

PRINT "number", a

INPUT #1: b

LET count = count+1

PRINT "number", b

INPUT #1: c

LET count = count+1

PRINT "number", c

PRINT "count",count

LET sum = a+b+c

LET average = sum/count

PRINT "average",average

END

 

Contents of file titled values.dat in same directory as the program:

 

3

4

5

Result of running program:

number 3

number 4

number 5

count 3

average 4