Radio Shack TRS-80 Model 100 Basic Manual page 47

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

Advertisement

If
you require more, then the CLEAR statement must be used. Since it is unlikely a
name will be longer than 256 characters, the above program should not need the
CLEAR statement.
If,
on the other hand, your program had twenty string variables, each of which is used
to hold a name, then the maximum of 256 would probably be exceeded. In this case,
the CLEAR statement would be needed.
Experiment #8 Mortgage Payment Calculation
Clear working memory with the NEW command and type the following program from
the keyboard:
1121
INPUT "INTEREST RATE
( 121
-
1121121 ) " ;
R
2121
R
=
R
/
1121121
3121
INPUT "AMOUNT OF LOAN
II ;
A
ill2l
INPUT "NUMBER OF YEARS"; T
5121
N
=
12
*
T
8121
I
=
R
/
12
7121
MP
=
( 1
-
( 1 +
I)~(-N»
/
I
8121
MP
=
A
/
MP
9121
PRINT "MONTHLY PAYMENT IS
$"
j
MP
When you execute this program, you will be prompted for the interest rate, the
amount of the loan and the length in years of the loan. If the interest rate is 12% then
12 should be entered, not .12. Here is an example of the execution of the program.
INTEREST RATE (0 -100)? 12
AMOUNT OF LOAN
?
30000
NUMBER OF YEARS
?
25
MONTHLY PAYMENT IS
$
315.967242659281
Line 10 allows the interest rate to be entered and stores it in variable R.
Line 20 converts the interest rate to a decimal value.
It
is important to note that the equals symbol
(=)
in a BASIC program means "assign
the value computed on the right side to the variable on the left side."
It
does not
mean the right side is equal to the left side as in an algebraic equation. Thus the
assignment statement:
R
=
R
/100
means to compute the right side, R / 100, and then store the result back in R.
Line 30 allows the amount of the loan to be entered and stored in numeric variable A.
Remember that numeric values are entered without a comma.
41

Advertisement

Table of Contents
loading

Table of Contents