Radio Shack TRS-80 PC-3 Owner's Manual page 188

Table of Contents

Advertisement

Loan Payment Calculator Program
10: INPUT "PRINCIPAL? "; P
20: INPUT "VEARLV
~
INTERESn"; I
30: I = 1/12
40: 1=1/100
50: INPUT "MONTHS? "; N
60: T = (P*((1
+
I)"'N)) *,
70: B = (1
+
Il
A
N)-1
80: A = T/B
90: A = ( INT (A * 100)
+
.5))/100
100: PRINT "MO. PAVMENT=";A
110: Z = A *N
120: PRINT
"TOTAL~COST
=" ; Z
130: X = Z-P
140: PRINT
"TOTAL~INTEREST
=" ;
x
Get the amount borrowed
Get the interest for a whole year
Divide by 12 to get the interest for a month
Divide by 100 to turn percent into a decimal fraction
Get number of months
Compute top half of formula
Compute bottom half of formula
Divide top by bottom
Convert to even cents
Display monthly payment amount
Multiply monthly amount times months for total
Display total cost
Subtract principal from total cost to get interest
Pri nt interest
150: INPUT "ANOTHER? "; 0$
Ask for repeat
160: IF ( LEFT$ (0$,1) = "V") THEN GOTO 10
Go back to top if first character is 'V'
170: END
Otherwise end
Note: The computation in line 9QJ is a little programming "trick" for rounding off numbers to a desired precision. Multiplying by
1QJQJ moves the first two decimal digits to the left of the
d~8imal
point. Taking the integer part of this with the INT function
throws away any extra decimal digits. .5 is added first so thiftit will round up if the part which is to be thrown away is over .5.
The amount is then divided by 1QJQJ again to restore its prior scale.
188

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents