"Calculator" BASIC Program


The program gives you various options for what you would like to calculate.
So there is; Area of a triangle, Circumference of a circle, Area of a circle,
Volume of a cuboid, Volume of a prism, and a display of Trigonomic formulae.


The program uses Proceedures to define each type of calculation within the program.
Data is input and calculated using simple equasions and the results displayed.

Apart from that the program is just a basic exercise in variables and proceedures.

Here is the 1986 listing for CALCULATOR in BBC BASIC


10 REM CALCULATOR
20 REM
30 REM GUESS THE NUMBER
40 REM
50 REM By RICHARD HALL
60 REM
70 REM Written on the:
80 REM
90 REM Acorn Electron 32K
100 REM
110 REM Language:BBC BASIC
120 REM
130 *KEY10 OLD|M|G RUN|M
140 *FX200,1
150 VDU 23,240,56,124,124,254,0,254,124
160 MODE 6:CLS
170 REPORT
180 PRINT:PRINTSPC(8);"THE Acorn ";CHR$240;" CALCULATOR"
190 PRINTSPC(8);"~~~ ~~~~~ ~ ~~~~~~~~~~"
200 PRINT:PRINTSPC(16);"MENU":PRINTSPC(16);"~~~~"
210 PRINT:PRINT
220 PRINTSPC(2);"1)";SPC(2);"Area of a Triangle"
230 PRINTSPC(2);"2)";SPC(2);"Circumference of a Circle"
240 PRINTSPC(2);"3)";SPC(2);"Area of a Circle"
250 PRINTSPC(2);"4)";SPC(2);"Volume of a Cuboid"
260 PRINTSPC(2);"5)";SPC(2);"Volume of a Prism"
270 PRINTSPC(2);"6)";SPC(2);"Trigonerical Formulae"
280 PRINTSPC(2);"7)";SPC(2);"EXIT Program"
290 PRINT:PRINT
300 INPUT TAB(2)"Your Choice";ch
310 IF ch=1 THEN PROCtriangle:CLEAR:RUN
320 IF ch=2 THEN PROCcircumcirc:CLEAR:RUN
330 IF ch=3 THEN PROCareacird:CLEAR:RUN
340 IF ch=4 THEN PROCvolcuboid:CLEAR:RUN
350 IF ch=5 THEN PROCvolprism:CLEAR:RUN
360 IF ch=6 THEN PROCtrigform:MODE6:CLEAR:RUN
370 IF ch=7 THEN PROCexitprog:RUN
380 IF ch<=0 OR ch>=7 THEN RUN
390
400 ***********************************
410
420 DEFPROCtriangle:CLS
430 PRINT:PRINTSPC(8);"THE AREA OF A TRIANGLE"
440 PRINTSPC(8);"~~~ ~~~~ ~~ ~ ~~~~~~~"
450 PRINT:PRINT
460 PRINTSPC(2);"ENTER THE APPROPRIATE DATA IN CM's"
470 PRINT:INPUTSPC(2);"ENTER THE LENGTH OF THE BASE";base
480 PRINT:INPUTSPC(2);"ENTER THE PERPENDICULAR HEIGHT";height
490 LET area=base*height/2
500 PRINT:PRINT"The area of the triangle is ";area;" CM's 2"
510 PRINT:PRINTSPC(2)"<SPACE> TO CONTINUE"
520 IF GET=32 THEN ENDPROC
530 DEFPROCcircumcirc:CLS
540 PRINT:PRINTSPC(5);"THE CIRCUMFERENCE OF A CIRCLE"
550 PRINTSPC(5);"~~~ ~~~~~~~~~~~~~ ~~ ~ ~~~~~~"
560 PRINT:PRINT
570 PRINTSPC(2);"ENTER THE APPROPRIATE DATA IN CM's"
580 PRINT:INPUTSPC(2);"ENTER THE RADIUS";radius
590 LET circumference=2*PI*radius
600 PRINT:PRINT" The Circumference"'"of the circle is:";circumference
610 PRINT:PRINTSPC(2);"<SPACE> TO CONTINUE":REPEAT UNTIL GET=32:ENDPROC
620 DEFPROCareacirc:CLS
630 PRINT:PRINTSPC(8);"THE AREA OF A CIRCLE"
640 PRINTSPC(8);"~~~ ~~~~ ~~ ~ ~~~~~~"
650 PRINT:PRINT
660 PRINTSPC(2);"ENTER THE APPROPRIATE DATA IN CM's"
670 PRINT:INPUTSPC(2);"ENTER THE RADIUS";radi
680 LET areac=PI*(radi*radi)
690 PRINT:PRINT" The Area"'"of the circle is:";areac
700 PRINT:PRINTSPC(2);"<SPACE> TO CONTINUE":REPEAT UNTIL GET=32:ENDPROC
710 DEFPROCvolcuboid:CLS
720 PRINT:PRINTSPC(8);"THE VOLUME OF A CUBOID"
730 PRINTSPC(8);"~~~ ~~~~~~ ~~ ~ ~~~~~~"
740 PRINT:PRINT:PRINTSPC(2);"ENTER THE APPROPRIATE DATA IN CM's"
750 PRINT:INPUTSPC(2);"ENTER THE LENGTH";len
760 PRINT:INPUTSPC(2);"ENTER THE BREADTH";bre
770 PRINT:INPUTSPC(2);"ENTER THE HEIGHT";hei
780 LET ar=len*bre*hei
790 PRINT:PRINT" The Volume"'"of the Cuboid is:";ar
800 PRINT:PRINTSPC(2);"<SPACE> TO CONTINUE":REPEAT UNTIL GET=32:ENDPROC
810 DEFPROCvolprism:CLS
820 PRINT:PRINTSPC(9);"THE VOLUME OF A PRISM"
830 PRINTSPC(9);"~~~ ~~~~~~ ~~ ~ ~~~~~"
840 PRINT:PRINT
850 PRINTSPC(2);"ENTER THE APPROPRIATE DATA IN CM's"
860 PRINT:INPUTSPC(2);"ENTER THE LENGTH";leth
870 PRINT:INPUTSPC(2);"ENTER THE CROSS SECTION";cross
880 LET volume=leth*cross
890 PRINT:PRINT" The Volume"'"of the Prism is:";volu
900 PRINT:PRINTSPC(2);"<SPACE> TO CONTINUE":REPEAT UNTIL GET=32:ENDPROC
910 DEFPROCtrigform:CLS
920 PRINT:PRINTSPC(8);"TRIGONOMETRICAL FORMULAE"
930 PRINTSPC(8);"~~~~~~~~~~~~~~~ ~~~~~~~~"
940 PRINT:PRINT
950 PRINTSPC(2)"In a Right Angled Trinagle:"
960 PRINT:PRINT
970 PRINTSPC(9);"Opposite side"
980 PRINT "Sine @= _____________"
990 PRINTSPC(10)"Hypotenuse"
1000PRINT:PRINT
1010 PRINTSPC(11);"Adjacent side"
1020 PRINT"cosine @= _______________"
1030 PRINTSPC(12)"Hypotenuse"
1040 PRINT:PRINT
1050 PRINTSPC(12);"Opposite side"
1060 PRINT"tangent @= ________________"
1070 PRINTSPC(12)"Adjacent side"
1080 PRINTTAB(33,20)"@"
1090 PRINT:PRINT" Pythagoras' Theorem";TAB(43)"ADJACENT"''"(Hypotenuse)*2=(Opposite)*2+(Adjacent)*2"
1100 MOVE 450,350:DRAW 1200,350:DRAW 1200,1000:DRAW 450,350:MOVE 600,350:DRAW 600,375:DRAW 575,400:DRAW550,427:MOVE 1000,350:DRAW 1000,475:DRAW 1200,475
1110 PRINTTAB(35,11)"HYPOTENUSE":PRINTTAB(65,11)"OPPOSITE"
1120 PRINTTAB(2,26)"SPACE TO CONTINUE"
1130 REPEAT UNTIL GET=32:ENDPROC
1140 DEFPROCexitprog:CLS
1150 INPUTTAB(10,10);"ARE YOU SURE (Y/N)";exit$
1160 IF exit$="Y" OR exit$="y" THEN STOP
1170 IF exit$="N" OR exit$="n" THEN ENDPROC

Back to School Programs Page


If you have arrived here from a Search Engine
Click the link below to go to the Classic Acorn Home Page
Everyone else use the Navigation Section on the Left
<---------------------------------------------------

Home