Radio Shack TRS-80 Model 100 Basic Manual page 41

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

Advertisement

It
would be more convenient if you could simply type in the values for the variables
as the program is being executed.
The program will be changed so that the value for P, the principal, can be entered
during execution. The values for the other variables will be assigned, as before, with
assignment statements.
.
Change line 10 to
10 PRINT "ENTER THE PRINCIPAL";
and insert line 15
15
INPUT P
List the program to verify that
it
is:
10 PRINT "ENTER THE PRINCIPAL";
15
INPUT P
20 R
= •
12
30
T = 5
40
K = 4
508=
P
*
(1
+
R /
K)h(T
*
K)
60
PRINT "TOTAL
18 $"; 8
Execute the program.
When the program executes, the following message (called a "prompt") will be
displayed:
ENTER THE PRINCIPAL?
and the computer will wait for you to enter the value for P. When a value for P is
entered, for example 5000, the program will execute as before and print out the total.
Be sure to press
CENTER)
after typing the amount for P.
Here is what the output looks like:
ENTER THE PRINCIPAL?
5000
TOTAL
18
$
8030.5561733465
Line 10 prints the prompt message. The semicolon at the end of the line suppresses
the carriage return so that the next character printed will be on the same line.
Line 15 is the INPUT statement. When this statement is executed, a question mark is
printed and the computer will wait for you to enter a number from the keyboard. After
you type the number and press
(ENTER),
the number will be assigned to the variable P
which appears after INPUT.
The remainder of the program is the same as before.
If the semicolon is left out in line 10, then the question mark and the number you type
will be printed on the next line below the prompt.
35

Advertisement

Table of Contents
loading

Table of Contents