Where | T= period in years. |
P= principal. | |
R= rate of interest. | |
N= number of payments each year. | |
A= amount of each payment. |
This program could be improved by designing a more robust input routine, to check for bad keyboard input.
COMMANDS
Key in program and type RUN.
Follow instructions.
100 REM Program P20 - Loan Repayment Period 110 MODE 6 120 PRINT "If you are about to take out a loan " 130 PRINT "it could be useful to consider how long" 140 PRINT "it will be before the loan is repaid." 150 PRINT "To use this program you must input "'' 160 PRINT TAB(5)"Amount borrowed" 170 PRINT TAB(5)"Annual interest rate" 180 PRINT TAB(5)"Number of payments per year" 190 PRINT TAB(5)"Amount of payments" 200 PRINT ''"Press any key to continue" 210 Z=GET 220 CLS 230 INPUT TAB(5,6)"Amount borrowed `"P 240 INPUT TAB(5)"Annual interest rate (%) "rate:rate=rate/ 100 250 INPUT TAB(5)"Number of payments per year "N 260 INPUT TAB(5)"Amount of payments `" A 270 time=-LOG(1-P*rate/N/A)/LOG(1+rate/N)/N 280 year=INT(time) 290 months=INT(12*(time-year)+.5) 300 PRINT '''"Loan will be paid off in ";year;" years and "';months;" months" 310 END
P21 Depreciation
This program can be used to calculate the depreciation in the value of an asset arising from normal use through time.
The program shows the effect of two common methods of calculating this depreciation.
100 REM Program P21 - Depreciation 110 MODE 6 120 PRINT TAB(2,2);"Depreciation calculations" 130 PRINT ''' 140 PRINT "There are 2 common methods of" 150 PRINT "calculating the amount of depreciation" 160 PRINT "for a given period. These are:" 170 PRINT ''"1. The straight line method" 180 PRINT "2. The diminishing balance method" 190 PRINT ''"This program shows depreciation over" 200 PRINT "a fixed period, using both methods." 210 PRINT ''"Press any key to continue" 220 g=GET 230 CLS 240 INPUT "Value of asset on acquisition",init_value 250 INPUT "Fixed amount to be written off annually ",amoun t 260 INPUT "Percentage to be written off manually ",perce ntage 270 INPUT "No of years to be presented ",years 280 PRINT ''"Press any key to continue" 290 g=GET 300 CLS 310 @%=LEN(STR$(init_value)) 320 val_2=init_value 330 PRINT "Year";TAB(15);"Value 1";TAB(30);"Value 2" 340 FOR I=1 TO years 350 val_1=init_value - amount*I 360 IF val_1<0 THEN val_1=0 370 val_2=val_2*(100 - percentage)/100 380 IF val_2<0 THEN val_2=0 390 PRINT I;TAB(15);INT(val_1);TAB(30);INT(val_2) 400 NEXT I 410 END
P22 Four-weekly Moving Average
When attempting to measure trends in sales data it can be useful to plot the sales data along with a continually updated average of the last four weeks' sales.
This program performs such a task, with the sales data held in the form of data statements. Note that the data is terminated by an imaginary negative sale.
COMMANDS
Key in program and type RUN.
Follow instructions.
100 REM Program P22 - Four-weekly Moving Average 110 DIM sales(53),movav(50) 120 MODE 6 130 PRINT "This program can be used to help you" 140 PRINT "to forecast sales based on a graph of " 150 PRINT "a 4-weekly moving average." 160 PRINT ''"This can be a fairly useful program," 170 PRINT "but bear in mind that it does not" 180 PRINT "consider seasonal variation." 190 PRINT''' 200 PRINT "Data is held in DATA statements, and" 210 PRINT "up to 52 weeks can be handled." 220 PRINT ''"If necessary escape from the program" 230 PRINT "and add to the data." 240 PRINT ''"Hit any other key to continue" 250 x=GET 260 270 REM Scale the data 280 no=0:max_sales=0 290 REPEAT 300 no=no+1 310 READ sales(no) 320 IF max_sales<sales(no) THEN max_sales=sales(no) 330 UNTIL sales(no)<0 340 350 FOR I=4 TO no-1 360 movav(I-3)=(sales(I)+sales(I-1)+sales(I-2)+sales(I-3 ))/4 370 NEXT I 380 390 400 REM Draw axes 410 MODE 5 420 VDU 19,0,7;0;19,3,0;0; 430 COLOUR1 440 PRINT '" Weekly Sales - 1982" 450 MOVE 16,0:DRAW 16,1023 460 MOVE 0,100:DRAW 1279,100 470 X=0 480 FOR I=1 TO 13 490 FOR J=1 TO 3 500 MOVE 16+X+J*24,90 510 DRAW 16+X+J*24,110 520 NEXT J 530 MOVE 16+X+96,80 540 DRAW 16+X+96,120 550 X=X+96 560 NEXT I 570 PRINT TAB(1,30)" 2 4 6 8 10 12"; 580 590 vert_unit=max_sales DIV 20 600 VDU 5 610 FOR I=1 TO 20 630 MOVE 12,100+I*40 640 DRAW 30,100+I*40 650 IF I MOD 4=0 THEN PRINT;I*vert_unit; 660 NEXT I 670 680 scale=40/vert_unit 690 MOVE 40,scale*sales(1)+100 700 GCOL 0,2 710 FOR I= 2 TO no-1 720 DRAW I*24,scale*sales(I)+100 730 NEXT I 740 750 GCOL 0,1 760 MOVE 64,scale*movav(1)+100 770 FOR I=2 TO no-4 780 DRAW I*24+64,scale*movav(I)+100 790 NEXT I 800 810 X=GET:REM wait till key is pressed 820 DATA 112,224,115,212,118,215,113,214,115,216,112,223,1 26,224,125,265,145,293,116,216,193,293 830 DATA 187,315,220,354,232,367,198,354,267,365,287,398,2 54,254,176,234,144,201,101,350,190,483 840 DATA 190,190 850 DATA -9
P23, P24 and P25 Stock Control
These three programs form a rudimentary stock control system. Program 23 is used to set up the stock control file initially. Notice that in its present form there are only ten stock items. But I am sure that the reader would be able to amend the program to allow the inclusion of more than ten items.
Program P24 is used to record all transactions, both additions to and withdrawals from stocks. The program in its present state does not verify the data being entered; this would be a useful feature.
Program P25, the stock update and report program, is a rather complicated program and should be entered fairly carefully. I have attempted to make this program fairly self documented through the use of REM and PRINT statements.
It is not possible to use two tape files simultaneously on the ELECTRON microcomputer, therefore the first thing that P28 does is to read the stock file into memory for updating. The transaction file is then loaded into the recorder and is used to update the stockfile in memory.
COMMANDS
Have some blank tapes ready.
Key in programs and type RUN.
Follow instructions.
100 REM Program P23 - Stock File Creation 110 MODE 6 120 stocks=OPENOUT("stock_file") 130 PRINT "This program sets up a stock file of 10" 140 PRINT "stock items." 150 FOR I=1 TO 10 160 CLS 170 INPUT "Stock number "numbers_1 180 INPUT "Description "desc$ 190 INPUT "Number in stock "numbers_2 200 INPUT "Reorder level "numbers_3 210 INPUT "Reorder quantity "numbers_4 220 PRINT#stocks,numbers_1,desc$,numbers_2,numbers_3,num bers_4 230 NEXT I 240 CLOSE#stocks 250 END 100 REM Program P24 - Transaction File Creation 110 MODE 6 120 trans=OPENOUT("transfile") 130 PRINT "This program sets up a transaction file" 140 PRINT "for use in the stock control system" 150 REPEAT 160 CLS 170 PRINT "Enter transaction details " 180 PRINT "Enter -9 for last stock number" 190 PRINT ''' 200 INPUT "Stock_no" s 210 INPUT "Code 1-withdrawal, 2-addition "c 220 INPUT "Quantity "q 230 IF s=-9 THEN CLOE#trans ELSE PRINT#trans,s,c,q 240 UNTIL s=-9 250 END 100 REM Program P25 - Stock File Update and Report 110 REM This program is written as a series of modules, so lving each part of the problem 120 REM The first section sets up space for the stock file 130 REM The stock file is held in memory in the form of 2 arrays, the first being a string array to hold the descripti ons 140 REM The other is a 2 dimensional array containing the numeric data of the stock file 150 DIM description$(10),numbers(10,4) 160 REM We now read in the stock file 170 MODE 6 180 PRINT "Load stock file tape into cassette and rewind" 190 PRINT "Press any key when ready" 200 a$=GET$ 210 PRINT "Press PLAY on recorder 220 stocks=OPENIN("stock_file") 230 FOR I=1 TO 10 240 INPUT#stocks,numbers(I,1),description$(I),numbers(I, 2),numbers(I,3),numbers(I,4) 250 NEXT I 260 CLOSE#stocks 270 CLS 280 PRINT "The stock file is now in memory" 290 PRINT"Remove stock file and load transaction"'"file, r ewind if necessary" 300 PRINT"Hit any key when ready" 310 a$=GET$ 320 PRINT"Updating stock file" 330 trans=OPENIN("transfile") 340 REM The following section of code updates the stock fi le in memory 350 REPEAT 360 INPUT#trans,I,code,quantity 370 IF code=1 THEN numbers(I,2)=numbers(I,2)-quantity EL SE numbers(I,2)=numbers(I,2)+quantity 380 UNTIL EOF#trans 390 REM Stock file updated 400 CLOSE#trans 410 REM The following section of code prints all items to be reordered, and also writes the new version of the stock f ile to tape 420 CLS 430 PRINT"Load fresh tape into recorder and rewind" 440 PRINT"Hit any key when ready" 450 a$=GET$ 460 CLS 470 PRINT"Processing......" 480 PRINT"Items to be reordered:" 490 new_stock=OPENOUT("stock_file") 500 FOR I=1 TO 10 510 PRINT#new_stock,numbers(I,1),description(I),numbers( I,2),numbers(I,3),numbers(I,4) 520 IF numbers(I,2)<numbers(I,3) THEN PRINT numbers(I,1) ,description$(I),numbers(I,2),numbers(I,3),numbers(I,4) 530 NEXT I 540 CLOSE#new_stock 550 CLS 560 PRINT "Job finished - remove tape and label with today :s date" 570 END
P26 VAT Calculator
This program allows you to use the ELECTRON micro as an aid in calculating VAT.
The results of the calculation are presented, rounded to the nearest penny.
The user has the option of changing the current rate of VAT from 15%.
Note that none of the data are saved.
COMMANDS
Key in program and type RUN.
Enter data as required.
100 REM Program P26 - VAT Calculator 110 MODE 6 120 PRINT TAB(15,12)"V A T" 130 PRINT TAB(8,14)"C A L C U L A T O R" 140 Z=INKEY(300) 150 CLS 160 vat=.15 170 PRINT "Current rate of VAT is 15%" 180 PRINT "Do you wish to change this"; 190 INPUT res$ 200 IF LEFT$(res$,1)="Y" THEN INPUT "New rate (%) " rate:v at=rate/100 210 220 REPEAT 230 CLS 240 INPUT '''"Cost of item `"cost 250 PRINT ''"VAT = `";FNround(cost*vat) 260 PRINT ''"Total cost `";FNround(cost*(1+vat)) 270 INPUT '''"Another run",res$ 280 UNTIL LEFT$(res$,1)<>"Y" 290 END 300 310 DEF FNround(X)=INT(X*100+.5)/100
P27 True Rate of Interest
This program uses a simple approach to calculating the true rate of interest on a loan. The program assumes that repayments are made on a monthly basis.
To calculate the true rate of interest, we compute the amount of pound-months that have been borrowed. (One pound-month is equivalent to borrowing one pound for one month, or fifty pence for two months.) This is done in lines 280 to 310. We now know the equivalent amount borrowed as a percentage. We then multiply this ratio by twelve.
COMMANDS
Key in program and type RUN.
Follow instructions.
100 REM Program P27 - True Rate of Interest 110 @%=&2020A 120 MODE 6 130 PRINT "This program computes the TRUE RATE OF" 140 PRINT "INTEREST for a loan transaction." 150 PRINT '"The program requires the amount" 160 PRINT "borrowed, the annual interest rate" 170 PRINT "and the number of months over which" 180 PRINT "the loan is taken. The program assumes" 190 PRINT "simple interest only." 200 PRINT '' 210 INPUT "Amount borrowed "amount 220 INPUT "Annual interest rate (%) "rate 230 rate=rate/100 240 INPUT "Number of months "number 250 interest=amount*rate*number/12 260 capital_payback=amount/number 270 REM calculate inatemonthly basis 280 borrowed=0 290 FOR I=1 TO number 300 borrowed=borrowed+(amount - capital_payback*(I-1)) 310 NEXT I 320 true_interest_rate = 12*100*interest/borrowed 330 PRINT "True interest rate is "true_interest_rate"%" 340 END