# Home Financial Calculator for Atari ST

Patrick Parrish, Programming Supervisor*
Rarely has there been a program integrating as many useful loan and investment features as "Home Financial Calculator." It is versatile, easy to use, and flexible. Rapid recalculation features make it an ideal tool for "what if" projections. A calculator mode with memory lets you solve problems not directly supported by the program, and you can pass values generated by one calculation to another. "Home Financial Calculator" was originally published in the May 1985 issue of COMPUTE!. This new version is for any Atari ST computer which has TOS in ROM.
*

"Home Financial Calculator" integrates a number of common financial calculations in a menu-driven package. It also features a calculator mode or scratch pad area where program variables can be manipulated using common mathematical operations.

Be particularly careful when typing the long lines in this program which contain financial formulae. A mistyped program may still run, but the results it gives could be inaccurate.

When you run the program, a main menu offers you a choice of Investment or Loan calculations. Type I or L to reach the appropriate submenu.

#### Easy "What If" Projections

Before looking at any calculations, let's consider some basics of the program. Home Financial Calculator uses some parameters or variables repeatedly in the calculations. These variables are *Total* (also referred to as Future Value, Total Owed, and so forth, depending on the calculation); *Present Value* (principal); *Interest Rate*; *Years*; *Months*; *Number of Periods* (of either compounding, deposits, withdrawals, or payments, depending on the application); *Deposits*; and *Withdrawals*. When in the calculator mode (explained below), you'll reference these eight variables with the single letters T, P, I, Y, M, N, D, and W.

As you work with Home Financial Calculator, the values of the eight variables are preserved until you change them. Whenever the program asks you for an input (for example. Interest), the current value of that variable is displayed (zero if no value has been entered yet). If you want to keep the current value, just press Return. Otherwise, enter the new value and press Return.

With this feature. Home Financial Calculator makes it easy for you to generate "what if" projections. Simply run the same calculation repeatedly, each time changing a previously entered value. Press Return to keep a value, and change only one or two values to see the effect on the final result.

You can also store the current value into the calculator mode's Memory Register or recall a value from the Memory Register. To see how all this works, let's take a closer look at your options.

#### Your Investment Menu

Here is the Investment submenu that appears when you type I from the main menu:

1) Future Value with Periodic Interest 2) Future Value with Interest Compounded Continuously 3) Future Value with Regular Deposits 4) Future Value with Cash Flows 5) Withdrawal of Funds 6) Net Present Value 7) Calculator Mode 8) Return to Main Menu.

Determine which option you want and press the appropriate key.

Each option displays screen prompts which ask you to input several values. These values are stored in the eight variables mentioned above: *T* for Total (Future Value), *P* for Present Value (principal), *I* for Interest Rate, *Y* for Years, *M* for Months, *N* for Number of Periods, *D* for Deposits, and *W* for Withdrawals. Of course, not all calculations require you to enter all these values, while others may ask for additional information.

Most calculations can be solved for any *one* of the variables. To solve for a variable, enter an uppercase X at the corresponding input prompt. For example, you could enter values for everything except the Interest Rate, typing X at the Interest Rate prompt. Home Financial Calculator then solves for the Interest Rate.

Remember, however, that the program can solve for only one variable during each calculation. If you enter an X at more than one prompt, the program does not have enough information to calculate an answer.

#### Future Value With Periodic Interest

Home Financial Calculator's options are fairly self-explanatory when you run the program, but let's try an example. We'll calculate the future value of an investment drawing periodic interest. This kind of investment could be a savings account, interest-bearing checking account, bonds, or a money market account. Choose this option by entering 1 at the Investment submenu.

After the screen clears, the program asks for the first input—Future Value, which appears with an asterisk (*). Below this is a zero (the current value of this variable in memory; all variables start out with a value of zero). Following this is an input prompt.

The asterisk preceding Future Value means that this is one of the variables you can solve for. (A variable *not* preceded by an asterisk means that variable *cannot* be solved for in that particular calculation, so X would be an illegal response.) If you'd like to calculate the Future Value, enter an X here, and answer all the other prompts with the appropriate values.

Let's calculate the future value of a $1,000 investment drawing 8 percent interest for two years and three months, with four compounding periods each year. Enter an X for *Future Value*, since we'll be solving for this total. Answer *Present Value* with 1000 (the principal you're investing); *Annual Int Rate* (%) with 8 (enter the percentage, not a fraction); For *# Of Years* with 2; For *# Of Months* with 3; and *# Of Periods* (Compounding) with 4. After you enter the last value. Home Financial Calculator figures the *Total Future Value* and displays the answer— $1195.09.

Now suppose you wish to know the future value of the same $1,000 investment if you make 9 percent interest. Choose option 1 on the Investment submenu again and rerun the calculation. Notice how Home Financial Calculator automatically prints the current value of each variable at each prompt. *The Future Value* prompt shows a current value of 1195.09 from the previous calculation. Type an X at this prompt, 9 for Interest Rate, and Return at all other prompts to preserve their values. The result should be $1221.71.

The versatility of Home Financial Calculator becomes apparent when you realize how many different ways you can run this calculation. Using this same menu option, you can calculate the initial investment (or present value) necessary to accrue a certain future value with periodic interest; the interest rate necessary to accrue a future value from a present value; or the time (in years and months) it would take to accumulate a future amount from an initial investment with periodic interest payments. Just enter an X for the unknown value you're seeking and fill in all the other prompts.

#### Future Value With Interest Compounded Continuously

Option 2, a variation of option 1, handles investments paying a continuous interest rate. Like option 1, option 2 can handle a number of calculations—just place an X in the slot you'd like to solve for.

Here, after entering all other parameters, you can calculate the future value of an investment; the initial investment required to reach a certain future value; the interest required to reach a desired future value; or the time required to reach a certain future value at a specified interest rate.

Notice that any variables used in option 1 will be displayed with their current values when running option 2. Recall that the eight major variables in Home Financial Calculator retain their values throughout the program until you change them. This feature is convenient when going from one option to another on the Investment or Loan submenus.

In addition, the values are preserved for use in the calculator mode. For instance, you could compare the effect of continuously compounded interest to periodic interest (option-1) without having to retype the input.

#### Future Value With Regular Deposits

If you're interested in setting up an annuity, you'd choose option 3 on the Investment submenu. You can determine the future value of an account (such as a savings account, Individual Retirement Account, or college or vacation fund) with regular deposits where interest is compounded with each deposit.

Option 3 can also tell you the amount of each deposit necessary to accrue a future value; the interest rate needed to provide some future value with regular deposits; or the time it would take to amass a future value with regular deposits.

#### Future Value With Cash Flows

Option 4 does a single calculation—it always solves for *Future Value*, so don't enter an X anywhere. It calculates the future value of an investment with yearly cash flows (either positive or negative). The *Annual Interest Rate* you input here is the growth rate on the money you've invested.

As an example, suppose you wish to determine the value of a vacation fund collected over four years. You're asked for the number of years, then for the deposit or withdrawal each year. You deposit $500 in the fund the first year and $200 the second. The third year you are forced to withdraw $300 (entered as -300), and the fourth year, you put in $400. The fund has a growth rate of 12 percent. Its value after four years will be $1,017.34.

A future value determination can also tell you whether an investment is worthwhile. If the future value of all cash flows is positive or zero, the investment is profitable. A negative future value, on the other hand, represents a losing investment.

#### Withdrawal Of Funds

If you intend to open an account from which you can regularly withdraw funds, choose option 5. With this option, you can determine the initial deposit required in the account to cover your withdrawals; the amount you can withdraw regularly from this account; the rate of interest you must make on funds in the account; or the period of time over which you can make withdrawals.

#### Net Present Value

Option 6 lets you determine the feasibility of a prospective investment by calculating its net present value. Net present value is the current value of all future yearly cash flows to an investment along with any initial cash requirement. The interest rate you input here is the rate of return you require on your investment. A positive net present value indicates a profitable investment, while a negative result signifies a losing investment.

As an example, suppose you have the opportunity to make a $2,000 investment which would return $1,500 the first year, cost you $750 the second year, and return $1,900 the third year. You hope to make 13 percent on your money. With option 6, you would determine a net present value of $56.87, representing a profitable investment.

#### The Calculator Mode

Option 7 puts you in the calculator mode (also available from the Loan submenu). Calculator mode works very much like a hand-held calculator with a single memory. You can type in a value or recall one from a variable by entering its symbol—T(otal), P(resent Value), I(nterest Rate), Y(ears), M(onths), N(umber of Periods), D(eposits), and W(ithdrawals). You can perform simple math on values stored in the Memory Register using reverse Polish notation. And you can use the results in future calculations.

When you enter calculator mode, the calculator command line appears on the screen:

V S H R M+ M- M* M/ MR MC MEM=0

Here are the commands:

V | View the values of the eight primary variables |

S | Store Memory Register into a variable |

H | Help-prints the command line |

R | Return to main menu, exit calculator mode |

M+ | Add the last input to the Memory Register |

M- | Subtract the last input from the value in the Memory Register and store the result in the Register |

M* | Multiply the last input times the value in the Memory Register and store the result in the Register |

M/ | Divide the last input into the value in the Memory Register and store the result in the Register |

MR | Memory Recall |

MC | Memory Clear to zero |

MEM= | Memory Register's current value |

If you've run through a sample investment calculation, you now have some variables in memory. Enter V in the calculator mode to see them. The screen displays the eight values currently in memory for the eight variables.

To work with one of these variables, enter one of their letters (T, P, I, Y, M, N, D, or W) and press Return. Then type M+ to add it to the Memory Register (all variables must be stored in the Register before you can perform any operations on them). Suppose you put the current value for T into the Register and now wish to add $229 to this value. Enter 229, press Return, then type M+ and press Return. The addition is performed and the result displayed. To store this value back into the T variable, enter S for Store. A prompt appears, requesting the variable in which you intend to store the value. Type T to store the value into the variable T.

You can also use the Memory Register to hold a value not represented by any of the eight variables. To do this, determine a value using the calculator mode and store it into the Memory Register with M+. Then, when you're running a calculation elsewhere in the program, you can substitute this value for any of the eight primary variables by typing MR (Memory Recall) at the appropriate prompt. MR can be used both in the calculator mode and at any prompt where the previous value is displayed.

Finally, option 8 on the Investment submenu returns you to the main menu. Once there, you can perform some loan calculations by typing L.

#### Loan Calculations

Here is the Loan calculations submenu:

1) Regular Loan Payments 2) Remaining Loan Liability 3) Final Loan Payment 4) Single Payment Loan 5) Loan Amortization Schedule 6) Calculator Mode 7) Return to Main Menu

#### Regular Loan Payments

Option 1 handles a number of calculations for equal payment loans. You can figure the principal of a loan; the amount of each regular payment necessary to repay a loan; the annual interest rate on a loan with regular payments; or the term of the loan.

#### Remaining Loan Liability

With option 2, you can determine the remaining balance on a loan with regular payments after a number of payments have been made. Enter the principal on the loan, the amount of each payment, the annual interest rate, the number of payments yearly, and the last payment number.

#### Final Loan Payment

Option 3 calculates the amount of the final payment on a loan. In many cases, the last payment of a loan will vary from the amount of the regular payment. This option handles situations where the final payment is greater than ("balloon payments") or less than the regular payment.

#### Single Payment Loan

Option 4 calculates the amount owed on a loan that is paid off with a single payment. You must input the principal on the loan, its annual interest rate, its term in years and months, and the number of times a year the interest on the principal is compounded.

#### Loan Amortization Schedule

Option 5 displays a loan amortization schedule. Enter the principal on the loan, the amount of each payment, the annual interest rate, the term of the loan, and the number of payments yearly. Then enter the period of the year in which the loan began (for instance, 10 for October) and the range in years of the amortization schedule you'd like to examine.

Because of the complexity of these calculations, there may be a delay before the output appears on the screen, especially if you have chosen to look at the latter years in a long-term loan repayment schedule (such as a home mortgage). When the amortization table appears, it displays the payment number, the beginning balance for the period, the amount paid toward the loan principal, the amount paid in interest, and the ending balance. To keep the information from scrolling off the screen, the program shows only a few payment periods at a time. Press Return to view another screenful. When the end of a year is reached, the program gives the total amounts paid on the principal and in interest for the year. In addition, when the last period of the loan is reached, the program displays the final payment for the loan.

The last two options on the Loan submenu are the same as those on the Investment submenu.

#### Modifying The Program

Home Financial Calculator is written in a modular format for easy modification. For many routines, it uses common input labels (lines 4590-4960) and some output labels (lines 4970-5050). If you want to add an investment or loan calculation routine, choose the labels from these lines that fit your application.

Also, you may wish to add a printer option to the loan amortization schedule. Examine lines 3140-3840. Here, variable D5 (defined in line 140) determines the number of loan payments considered on each screen. Variables S1, S2, S3, and S4 (defined in lines 150-180) format the output horizontally on the screen.

#### Home Financial Calculator For Atari ST

*Version by George Miller, Assistant Technical Editor*

10 GOSUB 5340 20 RES = PEEK(SYSTAB+0) 30 IF RES <> 4 THEN 60 40 ?"Please switch to Medium or High" 50 ?"Resolution.":STOP 60 COLOR 1,1 70 DIM V(8) 80 V$="TPIYMNDW" 90 C$="VSHR" 100 C0$="V S H R " 110 C1$="M+ M- M* M/ MR MC" 120 C2$="M+M-M*M/MRMC" 130 Q$="" 140 D5=12 150 S1=10 160 S2=25 170 S3=40 180 S4=55 190 TITLE$=" Home Financial Calculator "+CHR$(0) 200 GOSUB 5340:GOSUB TITLEBAR 210 PRINT "INVESTMENTS OR LOANS? (Select 'I' or 'L')" 220 A$=CHR$(INP(2)) 230 IF A$="I" OR A$="i" THEN 260 240 IF A$="L" OR A$="l" THEN 2120 250 GOTO 220 260 GOSUB 5340 270 TITLE$=" INVESTMENTS ":GOSUB TITLEBAR 280 GOTOXY 10,5: PRINT "1) FUTURE VALUE WITH PERIODIC INTEREST" 290 GOTOXY 10,6: PRINT "2) FUTURE VALUE WITH INTEREST COMPOUNDED CONTINUOUSLY" 300 GOTOXY 10,7: PRINT "3) FUTURE VALUE WITH REGULAR DEPOSITS" 310 GOTOXY 10,8: PRINT "4) FUTURE VALUE WITH CASH FLOWS" 320 GOTOXY 10,9: PRINT "5) WITHDRAWAL OF FUNDS" 330 GOTOXY 10,10:PRINT "6) NET PRESENT VALUE" 340 GOTOXY 10,11:PRINT "7) CALCULATOR MODE" 350 GOTOXY 10,12:PRINT "8) RETURN TO MAIN MENU" 360 GOTOXY 10,14:PRINT "YOUR CHOICE?"; 370 A=INP(2)-48 380 IF A<1 OR A>8 THEN 370 390 ON A GOTO 420,680,920,1310,1500,1890,400,190 400 GOSUB 4060 410 GOTO 190 420 GOSUB 5340 430 TITLE$=" FUTURE VALUE WITH PERIODIC INTEREST ":GOSUB TITLEBAR 440 PRINT 450 GOSUB 4590 460 GOSUB 4630 470 PRINT "*"; 480 GOSUB 4720 490 PRINT "*"; 500 GOSUB 4760 510 IF E=4 THEN 530 520 GOSUB 4800 530 GOSUB 4850 540 IF E<>1 THEN 570 550 V(1)=INT(V(2)*(1+V(3)/V(6))^(V(6)*Y)*100+.5)/100 560 GOSUB 4970 570 IF E<>2 THEN 600 580 V(2)=INT(V(1)/((1+V(3)/V(6))^(V(6)*Y))*100+.5)/100 590 GOSUB 5000 600 IF E<>3 THEN 630 610 V(3)=INT((V(6)*(V(1)/V(2))^(1/(V(6)*Y))-V(6))*10000+.5)/10000 620 GOSUB 5030 630 IF E<>4 THEN 660 640 V(4)=LOG(V(1)/V(2))/(V(6)*LOG(1+V(3)/V(6))) 650 GOSUB 5060 660 GOSUB 5210 670 GOTO 260 680 GOSUB 5340 690 TITLE$=" FUTURE VALUE WITH INTEREST COMPOUNDED CONTINUOUSLY ":GOSUB TITLEBAR 700 PRINT 710 GOSUB 4590 720 GOSUB 4630 730 PRINT "*"; 740 GOSUB 4720 750 PRINT "*"; 760 GOSUB 4760 770 IF E=4 THEN 790 780 GOSUB 4800 790 IF E<>1 THEN 820 800 V(1)=INT(V(2)*EXP(V(3)*Y)*100+.5)/100 810 GOSUB 4970 820 IF E<>2 THEN 850 830 V(2)=INT(V(1)/EXP(V(3)*Y)*100+.5)/100 840 GOSUB 5000 850 IF E<>3 THEN 880 860 V(3)=INT(LOG(V(1)/V(2))/Y*10000+.5)/10000 870 GOSUB 5030 880 IF E<>4 THEN 660 890 V(4)=INT(LOG(V(1)/V(2))/V(3)*100+.5)/100 900 GOSUB 5060 910 GOTO 660 920 GOSUB 5340 930 TITLE$=" FUTURE VALUE WITH REGULAR DEPOSITS ":GOSUB TITLEBAR 940 PRINT 950 GOSUB 4590 960 PRINT "*REGULAR DEPOSIT $" 970 C=6 980 GOSUB 3850 990 PRINT "*"; 1000 GOSUB 4720 1010 PRINT "*"; 1020 GOSUB 4760 1030 IF E=4 THEN 1050 1040 GOSUB 4800 1050 GOSUB 4850 1060 IF E<>1 THEN 1090 1070 V(1)=INT(V(7)*V(6)*((1+V(3)/V(6))^(V(6)*Y)-1)/V(3)*100+.5)/100 1080 GOSUB 4970 1090 IF E<>3 THEN 1230 1100 V(3)=.99 1110 I=0 1120 T=INT(V(7)*(((1+V(3)/V(6))^(V(6)*Y)-1)/(V(3)/V(6)))*100+.5)/100 1130 TE=ABS(V(3)-I)/2 1140 I=V(3) 1150 IF ABS(T-V(1))/V(1)<.00005 THEN 1210 1160 IF T<V(1) THEN 1190 1170 V(3)=V(3)-TE 1180 GOTO 1120 1190 V(3)=V(3)+TE 1200 GOTO 1120 1210 V(3)=INT(V(3)*10000+.5)/10000 1220 GOSUB 5030 1230 IF E<>4 THEN 1260 1240 V(4)=LOG(V(3)*V(1)/(V(6)*V(7))+1)/(V(6)*LOG(1+V(3)/V(6))) 1250 GOSUB 5060 1260 IF E<>7 THEN 660 1270 V(7)=INT(V(1)*(V(3)/V(6))/((1+V(3)/V(6))^(V(6)*Y)-1)*100+.5)/100 1280 PRINT 1290 PRINT "REGULAR DEPOSITS REQUIRED:$";V(7) 1300 GOTO 660 1310 GOSUB 5340 1320 TITLE$=" FUTURE VALUE WITH CASH FLOWS ": GOSUB TITLEBAR 1330 PRINT 1340 GOSUB 4720 1350 GOSUB 4760 1360 PRINT "CASH FLOW (+/-)" 1370 PRINT 1380 V(1)=0 1390 FOR I=1 TO V(4) 1400 PRINT "CASH FLOW - YEAR #";I 1410 INPUT A$ 1420 A=VAL(A$) 1430 V(1)=V(1)+A*(1+V(3))^(V(4)-I) 1440 NEXT I 1450 V(1)=INT(V(1)*100+.5)/100 1460 GOSUB 4970 1470 TE=V(1) 1480 GOSUB 5150 1490 GOTO 660 1500 GOSUB 5340 1510 TITLE$=" WITHDRAWAL OF FUNDS ":GOSUB TITLEBAR 1520 PRINT 1530 GOSUB 4630 1540 PRINT "*REGULAR WITHDRAWAL $" 1550 C=7 1560 GOSUB 3850 1570 PRINT "*"; 1580 GOSUB 4720 1590 PRINT "*"; 1600 GOSUB 4760 1610 IF E=4 THEN 1630 1620 GOSUB 4800 1630 GOSUB 4850 1640 IF E<>2 THEN 1670 1650 V(2)=INT(V(8)*V(6)/V(3)*(1-(1+V(3)/V(6))^(-V(6)*Y))*100+.5)/100 1660 GOSUB 5000 1670 IF E<>3 THEN 1810 1680 V(3)=.99 1690 I=0 1700 R=INT(V(2)*V(3)/V(6)*(1/((1+V(3)/V(6))^(V(6)*Y)-1)+1)*100+.5)/100 1710 TE=ABS(V(3)-I)/2 1720 I=V(3) 1730 IF ABS(R-V(8))/V(8)<.00005 THEN 1790 1740 IF R<V(8) THEN 1770 1750 V(3)=V(3)-TE 1760 GOTO 1700 1770 V(3)=V(3)+TE 1780 GOTO 1700 1790 V(3)=INT(V(3)*10000+.5)/10000 1800 GOSUB 5030 1810 IF E<>4 THEN 1840 1820 V(4)=LOG(V(6)*V(8)/(V(6)*V(8)-V(3)*V(2)))/(V(6)*LOG(1+V(3)/V(6))) 1830 GOSUB 5060 1840 IF E<>8 THEN 660 1850 V(8)=INT(V(2)*V(3)/V(6)*(1/((1+V(3)/V(6))^(V(6)*Y)-1)+1)*100+.5)/100 1860 PRINT 1870 PRINT "REGULAR WITHDRAWALS:$";V(8) 1880 GOTO 660 1890 GOSUB 5340 1900 PRINT "NET PRESENT VALUE:$" 1910 PRINT 1920 PRINT "INITIAL INVESTMENT" 1930 C=1 1940 GOSUB 3850 1950 GOSUB 4720 1960 GOSUB 4760 1970 PRINT "CASH FLOW (+/-)" 1980 PRINT 1990 NV=-V(2) 2000 FOR I=1 TO V(4) 2010 PRINT "CASH FLOW - YEAR #";I 2020 INPUT A$ 2030 A=VAL(A$) 2040 NV=NV+A/((V(3)+1)^I) 2050 NEXT I 2060 NV=INT(NV*100+.5)/100 2070 PRINT 2080 PRINT "NET PRESENT VALUE:$";NV 2090 TE=NV 2100 GOSUB 5150 2110 GOTO 660 2120 GOSUB 5340 2130 TITLE$=" LOANS ":GOSUB TITLEBAR 2140 GOTOXY 21,5: PRINT "1) REGULAR LOAN PAYMENTS" 2150 GOTOXY 21,6: PRINT "2) REMAINING LOAN LIABILITY" 2160 GOTOXY 21,7: PRINT "3) FINAL LOAN PAYMENT" 2170 GOTOXY 21,8: PRINT "4) SINGLE PAYMENT LOAN" 2180 GOTOXY 21,9: PRINT "5) LOAN AMORTIZATION SCHEDULE" 2190 GOTOXY 21,10:PRINT "6) CALCULATOR MODE" 2200 GOTOXY 21,11:PRINT "7) RETURN TO MAIN MENU" 2210 GOTOXY 21,13:PRINT "YOUR CHOICE?"; 2220 A=INP(2)-48 2230 IF A<1 OR A>7 THEN 2220 2240 ON A GOTO 2270,2690,2870,3030,3140,2250,190 2250 GOSUB 4060 2260 GOTO 190 2270 GOSUB 5340 2280 TITLE$=" REGULAR LOAN PAYMENTS ":GOSUB TITLEBAR 2290 PRINT 2300 PRINT "*"; 2310 GOSUB 4670 2320 PRINT "*"; 2330 GOSUB 4890 2340 PRINT "*"; 2350 GOSUB 4720 2360 PRINT "*"; 2370 GOSUB 4760 2380 IF E=4 THEN 2400 2390 GOSUB 4800 2400 GOSUB 4850 2410 IF E<>2 THEN 2460 2420 V(2)=INT(V(7)*V(6)/V(3)*(1-(1+V(3)/V(6))^(-V(6)*Y))*100+.5)/100 2430 PRINT 2440 PRINT "AMT OF PRINCIPAL:$";V(2) 2450 GOTO 2670 2460 IF E<>3 THEN 2600 2470 V(3)=.99 2480 I=0 2490 P=INT(V(7)*V(6)/V(3)*(1-((1+V(3)/V(6))^(-V(6)*Y)))*100+.5)/100 2500 TE=ABS(V(3)-I)/2 2510 I=V(3) 2520 IF ABS(P-V(2))/V(2) < .00005 THEN 2580 2530 IF P<V(2) THEN 2560 2540 V(3)=V(3)+TE 2550 GOTO 2490 2560 V(3)=V(3)-TE 2570 GOTO 2490 2580 V(3)=INT(V(3)*10000+.5)/10000 2590 GOSUB 5030 2600 IF E<>4 THEN 2630 2610 V(4)=-LOG(1-V(3)*V(2)/(V(6)*V(7)))/(V(6)*LOG(V(3)/V(6)+1)) 2620 GOSUB 5060 2630 IF E<>7 THEN 2670 2640 V(7)=INT(V(3)*V(2)/(V(6)*(1-(V(3)/V(6)+1)^(-V(6)*Y)))*100+.5)/100 2650 PRINT 2660 PRINT "REQ PAYMENT:$";V(7) 2670 GOSUB 5210 2680 GOTO 2120 2690 GOSUB 5340 2700 TITLE$=" REMAINING LOAN LIABILITY ": GOSUB TITLEBAR 2710 PRINT 2720 GOSUB 4670 2730 GOSUB 4890 2740 GOSUB 4720 2750 GOSUB 4850 2760 PRINT "LAST PAYMENT # WAS:" 2770 INPUT A$ 2780 A=VAL(A$) 2790 FOR J=1 TO A 2800 I=INT(P*V(3)/V(6)*100+.5)/100 2810 P=P+I-V(7) 2820 NEXT J 2830 LI=INT(P*100+.5)/100 2840 PRINT 2850 PRINT "LIABILITY AFTER ";A;" PAYMENTS:$"; LI 2860 GOTO 2670 2870 GOSUB 5340 2880 TITLE$=" LAST LOAN PAYMENT ":GOSUB TITLEBAR 2890 PRINT 2900 GOSUB 4670 2910 GOSUB 4890 2920 GOSUB 4720 2930 GOSUB 4930 2940 GOSUB 4850 2950 FOR J=1 TO V(6)*Y 2960 I=INT(P*V(3)/V(6)*100+.5)/100 2970 P=P+I-V(7) 2980 NEXT J 2990 LP=INT(P*100+.5)/100+V(7) 3000 PRINT 3010 PRINT "LAST PAYMENT:$";LP 3020 GOTO 2670 3030 GOSUB 5340 3040 TITLE$=" SINGLE PAYMENT LOAN ":GOSUB TITLEBAR 3050 PRINT 3060 GOSUB 4670 3070 GOSUB 4720 3080 GOSUB 4930 3090 GOSUB 4850 3100 V(1)=INT(V(2)*(1+V(3)/V(6))^(Y*V(6))*100+.5)/100 3110 PRINT 3120 PRINT "TOTAL OWED:$";V(1) 3130 GOTO 2670 3140 C5=0 3150 N5=0 3160 F=0 3170 P1=0 3180 I1=0 3190 GOSUB 5340 3200 TITLE$=" LOAN AMORTIZATION SCHEDULE ":GOSUB TITLEBAR 3210 GOSUB 4670 3220 GOSUB 4890 3230 GOSUB 4720 3240 GOSUB 4930 3250 PRINT "# OF PAYMENTS YEARLY" 3260 GOSUB 3850 3270 PRINT "ENTER THE PERIOD OF THE YEAR IN WHICH THE LOAN BEGAN" 3280 INPUT N 3290 NE=N 3300 NP=(V(4)*12+V(5))/(12/V(6)) 3310 NY=INT(((N-1)+NP)/V(6)+.99) 3320 PRINT "ENTER THE RANGE OF YEARS YOU'D LIKE TO EXAMINE (FIRST, LAST)" 3330 INPUT F1,L1 3340 IF L1<=NY THEN 3360 3350 L1=NY 3360 FOR J1=1 TO L1 3370 IF J1<F1 THEN 3390 3380 GOSUB 5250 3390 FOR J=1 TO V(6)-N+1 3400 I=INT(P*V(3)/V(6)*100+.5)/100 3410 N5=N5+1 3420 PP=V(7)-I 3430 IF J1<>NY THEN 3470 3440 IF N5<>NP THEN 3470 3450 PP=P 3460 F=1 3470 IF J1<F1 THEN 3500 3480 PRINT TAB(5);MID$(STR$(N5),2,LEN(STR$(N5))-1);TAB(S1);INT(P*100+.5)/100; 3490 PRINT TAB(S2);INT(PP*100+.5)/100;Q$;TAB(S3); 3500 P=P+I-V(7) 3510 IF F=0 THEN 3540 3520 P=0 3530 J=V(6) 3540 IF J1<F1 THEN 3570 3550 PRINT I;TAB(S4);INT(P*100+.5)/100; 3560 PRINT 3570 I1=I1+I 3580 P1=P1+PP 3590 C5=C5+1 3600 IF C5<>D5 THEN 3670 3610 IF J1<F1 THEN 3670 3620 GOSUB 5210 3630 GOSUB 5340 3640 C5=0 3650 IF J=V(6)-N+1 THEN 3670 3660 GOSUB 5250 3670 NEXT J 3680 IF J1<F1 THEN 3790 3690 IF F=0 THEN 3720 3700 GOTOXY 0,0 3710 PRINT "FINAL PAYMENT :$";INT((PP+I)*100+.5)/100 3720 PRINT 3730 PRINT "TOTAL INT PAID IN YR ";J1;":$";INT(I1*100+.5)/100 3740 PRINT "TOTAL PRINC PAID IN YR ";J1;":$";INT(P1*100+.5)/100 3750 IF F=1 THEN 3830 3760 IF J1=L1 THEN 3830 3770 GOSUB 5210 3780 GOSUB 5340 3790 C5=0 3800 P1=0 3810 I1=0 3820 N=1 3830 NEXT J1 3840 GOTO 2670 3850 C=C+1 3860 IF C<>3 THEN 3890 3870 PRINT V(3)*100, 3880 GOTO 3900 3890 PRINT V(C), 3900 INPUT A$ 3910 IF LEN(A$)<>0 THEN 3930 3920 RETURN 3930 IF A$<>"MR" THEN 3990 3940 PRINT "MEM=";M;" USE AS VARIABLE HERE (Y/N)" 3950 INPUT A$ 3960 IF A$="N" THEN 3900 3970 V(C)=M 3980 RETURN 3990 IF A$="X" THEN E=C: RETURN 4000 IF A$="x" THEN E=C: RETURN 4010 V(C)=VAL(A$) 4020 IF C<>3 THEN 4040 4030 V(C)=V(C)/100 4040 RETURN 4050 REM CALCULATOR MODE 4060 GOSUB 5340: TITLE$=" Calculator Mode ": GOSUB TITLEBAR 4070 M5=0 4080 GOSUB 4410 4090 INPUT A$ 4100 IF ASC(A$)>57 THEN 4130 4110 T=VAL(A$) 4120 GOTO 4090 4130 FOR I=1 TO 8 4140 IF A$<>MID$(V$,I,1) THEN 4170 4150 PRINT V(I) 4160 T=V(I) 4170 NEXT I 4180 FOR J=1 TO 6 4190 IF A$<>MID$(C2$,(J-1)*2+1,2) THEN 4210 4200 ON J GOSUB 4460,4480,4500,4520,4540,4560 4210 NEXT J 4220 FOR K=1 TO 4 4230 IF A$<>MID$(C$,K,1) THEN 4250 4240 ON K GOSUB 4290,4340,4410,4440 4250 NEXT K 4260 IF M5=0 THEN 4090 4270 M5=0 4280 RETURN 4290 FOR I=1 TO 8 4300 PRINT MID$(V$,I,1);" ";V(I) 4310 NEXT I 4320 PRINT 4330 RETURN 4340 PRINT "IN WHAT VARIABLE "; 4350 INPUT A$ 4360 FOR I=1 TO 8 4370 IF A$<>MID$(V$,I,1) THEN 4390 4380 V(I)=M 4390 NEXT I 4400 RETURN 4410 COLOR,2,1:GOTOXY 0,0:PRINT C0$;" ";C1$;" MEM=";M:COLOR 1,1 4420 PRINT 4430 RETURN 4440 M5=1 4450 RETURN 4460 M=M+T 4470 GOTO 4570 4480 M=M-T 4490 GOTO 4570 4500 M=M*T 4510 GOTO 4570 4520 M=M/T 4530 GOTO 4570 4540 T=M 4550 GOTO 4570 4560 M=0 4570 PRINT "MEM=";M 4580 RETURN 4590 PRINT "*FUTURE VALUE $" 4600 C=0 4610 GOSUB 3850 4620 RETURN 4630 PRINT "*PRESENT VALUE $" 4640 C=1 4650 GOSUB 3850 4660 RETURN 4670 PRINT "PRINCIPAL $" 4680 C=1 4690 GOSUB 3850 4700 P=V(C) 4710 RETURN 4720 PRINT "ANNUAL INT RATE (%)" 4730 C=2 4740 GOSUB 3850 4750 RETURN 4760 PRINT "FOR # OF YEARS" 4770 C=3 4780 GOSUB 3850 4790 RETURN 4800 PRINT "FOR # OF MONTHS" 4810 C=4 4820 GOSUB 3850 4830 Y=V(C-1)+V(C)/12 4840 RETURN 4850 PRINT "# OF PERIODS (COMPOUNDING, DEPOSITS, WITHDRAWALS, PAYMENTS) YEARLY" 4860 C=5 4870 GOSUB 3850 4880 RETURN 4890 PRINT "PAYMENTS $" 4900 C=6 4910 GOSUB 3850 4920 RETURN 4930 PRINT "TERM OF LOAN:" 4940 GOSUB 4760 4950 GOSUB 4800 4960 RETURN 4970 PRINT 4980 PRINT "FUTURE VALUE:$";V(1) 4990 RETURN 5000 PRINT 5010 PRINT "REQUIRED INVESTMENT:$";V(2) 5020 RETURN 5030 PRINT 5040 PRINT "ANNUAL INT RATE (%) REQUIRED:";V(3)*100 5050 RETURN 5060 V(5)=V(4)-INT(V(4)) 5070 V(5)=INT(INT(12*V(5)*10+.5)/10) 5080 V(4)=INT(V(4)) 5090 IF V(5)<>12 THEN 5120 5100 V(4)=V(4)+1 5110 V(5)=0 5120 PRINT 5130 PRINT "# OF YEARS AND MONTHS:";V(4);",";V(5) 5140 RETURN 5150 PRINT 5160 IF TE>=0 THEN 5190 5170 PRINT "THIS IS A LOSING INVESTMENT. " 5180 RETURN 5190 PRINT "THIS IS A PROFITABLE INVESTMENT." 5200 RETURN 5210 PRINT 5220 COLOR 2,2: PRINT "Press any key to continue";:"COLOR 1,1 5230 A=INP(2) 5240 RETURN 5250 GOSUB 5340 5260 PRINT "LOAN AMORTIZATION SCHEDULE FOR YR ";J1 5270 PRINT "PRIN $";V(2);" RATE ";V(3)*100;"%";" PAYM $";V(7) 5280 PRINT 5290 COLOR 3,1 5300 PRINT TAB(5);"#";TAB(11);"BEG BAL";TAB(26);"PRINC";TAB(41);"INT"; 5310 PRINT TAB(56);"END BAL" 5320 COLOR 1,1 5330 RETURN 5340 CLEARW 2:FULLW 2:GOTOXY 0,0 5350 RETURN 5360 TITLEBAR: 5370 A#=GB: GINTIN=PEEK(A#+8) 5380 POKE GINTIN+0,PEEK(SYSTAB+8):POKE GINTIN+2,2 5390 S#=GINTIN+4:TITLE$=TITLE$+CHR$(0) 5400 POKE S#,VARPTR(TITLE$):GEMSYS(105) 5410 RETURN