Almost everyone has, at one time or another, borrowed money. Loan Shark will enable you to calculate what the payments would be. "Big deal," you say. "Those programs are a dime a dozen."
Maybe so. Loan Shark, however, does more. A loan has four variables. They are: principal, interest rate, number of payments and payment amount. This program will compute any of them for you if you enter the other three.
Also, if you enter all four items, the remaining balance (or balloon payment) will be displayed. Each time you enter a set of data, all four items and the total interest paid will be displayed on the same line under their respective column headings. You can try many different combinations and compare results, since all data will remain on the screen.
To use the program, simply enter the values as they are requested at the bottom of the screen. Press RETURN without an entry to skip the unknown item. When entering the principal and number of payments data, you can enter two values separated by a plus, minus, multiplication or division sign.
This can save time, as you enter the number of years times twelve for the number of payments, without having to figure it out in advance. It's very handy when using data with a long repayment schedule (a home loan). You can enter the original amount minus the down payment when you are prompted for the principal, another timesaver.
In the unlikely event that you should fill the screen and then enter, more data, you will receive a prompt to turn your printer on, if you have one - or else copy the numbers you want to save. When you proceed, the screen will clear. If you do have a printer, the column headings and all data will be printed. The data can be printed at any time by entering P when prompted for the principal or number of payments.
The colors for the display were generated using Richard Kalagher's Multiple Screen Generator (in ANALOG Computing's issue 12).
Loan Shark uses graphics 0 with a text window. To employ this technique, first open a channel to write to the screen (OPEN #6,8,0,"S:"), then you can POKE 703,4. When you print to the upper twenty lines, use a PRINT #6 command. The top lines will not scroll with the bottom four lines, but will remain on the screen. The text window can then be used for input prompts and other instructions, and cleared with a simple clear screen command.
Following are three subroutines from this program which can, with minor changes, be incorporated into your programs.
1. (Lines 90 210) Format output, similar to a PRINT USING command in some BASICs.
Before the subroutine is called, set PIC$ equal to the format you want. Put the decimal point where you wish and include a dollar sign and/or trailing zeros, if desired. Set NU equal to the number you want formatted. Call the subroutine and PRINT FRM$ (Lines 870-960). Your number will be rounded to the number of places to the right of the decimal in PIC$ and trailing zeros will be added if you included them in PIC$.
Using this sbroutine, you can right justify, add trailing zeros, round off and include any special characters, all in one step. This is the most versatile formatting routine I have seen for the Atari.
2. (Lines 230-340) Two number input.
The BASIC on my pocket computer enables me to enter a series of numbers separated by arithmetic operators, all in one step. For instance, you can enter 247-119, and the value 128 will be entered. Atari BASIC does not allow this, so I wrote a simple subroutine enabling entry of a sign (+, -, *, /) between two numbers. You input to Q$, call the subroutine, and the variable X contains the result.
This subroutine, as used here, also checks for the print (P) and quit (Q) commands. Since it's used only when entering the principal and number of payments, the print and quit commands will only be recognized when entering these values.
3. (Lines 1040-1140) Graphics 0 screen dump.
This subroutine creates TEXT$ from a screen line, character by character. The outer FOR-NEXT loop contains the rows to be read, and the inner loop reads the columns. The column and row values can be changed so only part of the screen is sent to the printer. The inverse control T characters in Line 1100 are to underline the headings using a C.Itoh Prowriter. If you have a different printer, this character may have to be changed accordingly.
Here's a brief outline of the Loan Shark program.
Lines 90-210 - Right justify output and add trailing zeros.
Lines 230-340 - Allow two-number input, separated by +, -, *, or /.
Line 360 - Compute payment.
Lines 370-400 - Print heading and instruction lines.
Line 410 - Start of main program.
Lines 440-590 - Input data.
Line 610 - Compute principal.
Lines 650-730 - Compute interest rate using trial and error method.
Line 750 - Compute number of payments.
Line 810 - Compute balloon payment.
Line 830 - Compute total interest.
Lines 860-1020 - Print data to the screen.
Lines 1040-1140 - Print screen to printer
Lines 1150-1220 - Prompts to turn printer on or copy data to avoid loss.
Lines 1230-1260 - Clear screen of data.
Lines 1280-1520 - Screen color generator.
There you are. I hope Loan Shark helps you stay out of the hands of the Big Boys.
Marty Schmidt has been a pattern maker by trade, for twenty-one years. He's had an Atari 800 for the past two and one-half years and has been using it for family financial and record-keeping purposes, word processing and - let's not forget - entertainment.
BASIC listing. |
---|
50 REM ************************ 51 REM * LOANSHARK * 52 REM * BY * 53 REM * MARTY SCHMIDT * 54 REM ************************ 80 OPEN #6,8,K0,"S:":OPEN #2,4,K0,"S:" 90 A=34:POKE 559,K0:GOSUB 30000:POKE 7 12,186:POKE 559,A:GOTO 1000 95 REM FORMAT NUMBERS 100 FD=K0:FRM$=PIC$ 110 FOR J=1 TO LEN(FRM$) 120 IF FRM$(J,J)="." THEN FD=LEN(FRM$) -J:GOTO 140 130 NEXT J 140 IF FD=K0 THEN NUM$=STR$(INT(NU+0.5 )):GOTO 180 150 H=INT(10^FD+0.5) 160 NU=INT(NU*H+0.5)/H 170 NUM$=STR$(NU) 180 FOR K=1 TO LEN(NUM$) 190 IF NUM$(K,K)="." THEN 210 200 NEXT K 210 FRM$(J-K+1,J-K+LEN(NUM$))=NUM$ 220 RETURN 300 REM INPUT ROUTINE 310 FOR L=1 TO LEN(Q$):W=ASC(Q$(L,L)) 320 IF W=46 THEN 350 330 IF W=81 THEN POP :GRAPHICS K0:POKE 82,2:NEW 335 IF W=80 THEN TRAP 5300:GOSUB 5010: POP :GOTO 1040 340 IF W<48 OR W>57 THEN 370 350 NEXT L 360 X=VAL(Q$):RETURN 370 Y=VAL(Q$):Z=VAL(Q$(L+1,LEN(Q$))) 380 IF W=43 THEN X=Y+Z:RETURN 390 IF W=45 THEN X=Y-Z:RETURN 400 IF W=42 THEN X=Y*Z:RETURN 410 IF W=47 THEN X=Y/Z:RETURN 490 REM FIGURE PAYMENT 500 TEST=(P-B*(1+I)^-N)/((1-(1+I)^-N)/ I):RETURN 600 POSITION K0,K0:? #6;" PRINCIPAL APR # PAYMENT TOTAL INT";:RETURN 700 POSITION K0,19:? #6;"RETURN TO SKI P : P TO PRINT : Q TO QUIT";:RETURN 1000 POKE 82,K0:POKE 703,4:POKE 755,K0 :GOSUB 600:GOSUB 700 1010 DIM PIC$(15),FRM$(15),NUM$(15),Q$ (30),TEXT$(1000) 1030 REM INPUT DATA 1040 P=K0:Q=K0:N=K0:M=K0:TRAP 1300:GOS UB 700:POSITION K0,20:? " |
(see C:CHECK, D:CHECK or Unicheck) |
---|
50 DATA 275,615,999,968,287,293,752,15 2,741,140,177,739,486,511,5,7140 170 DATA 235,189,389,734,411,589,79,77 0,498,391,776,749,753,56,550,7169 380 DATA 222,233,196,219,385,964,575,5 47,405,235,892,444,582,724,963,7586 1070 DATA 581,693,728,938,565,932,933, 936,714,393,513,715,799,212,718,10370 1490 DATA 95,523,442,718,544,948,727,5 80,735,924,328,724,847,727,278,9140 1810 DATA 419,338,958,247,676,812,97,8 14,957,816,289,818,653,820,939,9653 2170 DATA 14,679,113,79,722,213,681,43 8,525,241,714,383,200,811,87,5900 5100 DATA 485,966,555,836,66,963,969,9 93,428,645,327,86,792,878,847,9836 30010 DATA 738,173,237,201,593,575,213 ,687,991,348,788,544,595,57,670,7410 30180 DATA 830,76,821,689,247,241,637, 233,497,4271 |