Radio Shack TRS-80 Model 100 Basic Manual page 43

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

Advertisement

Now list the program to verify that it is:
10 INPUT "PRINCIPAL, RATE"; P, R
30 T = 5
110
K
= II
50 S
=
P
*
(1
+
R /
K)h(T
*
K)
60 PRINT "TOTAL IS
$"
j
S
When you execute this program, the following prompt will
be
displayed
PRINCIPAL, RATE?
In response, you should enter two numbers separated by a comma. For example:
PRINCIPAL,RATE? 2000,
.111
and again the amount of the investment will be printed. The complete output will be:
RATE? 20lc10,
.14
3979.577"7269318
This program illustrates another option of the INPUT statement. Values for more than
one variable can be assigned with a single INPUT statement. The variables should be
separated by commas and listed after the prompt. When the INPUT statement is
executed, you must type a value for each variable, separating the values with commas.
After the last value has been typed, you should press (ENTER).
Two separate INPUT statements could have been used, the first for the principal P and
the second for the rate R as follows
113 INPUT "PRINCIPAL"; P
213 INPUT "RATE"; R
However, it is more convenient to use just a single statement as was done in the
program.
Experiment #6 Compound Interest with All
Variables Input
The previous program will be rewritten so that the values for all the variables can be
entered from the keyboard. The program will also be changed so that it will not
terminate after the total is printed. Instead, the program will ask again for values for
the variables so that the amount of the investment can be calculated for any number of
different values.
37
s

Advertisement

Table of Contents
loading

Table of Contents