I have programmed this Apple ][ Calculator:
5 SPEED = 150
10 PRINT "APPLE ][ CALCULATOR 1.0 BY MATTEO TREVISAN"
20 HOME
30 PRINT "DO YOU WANT TO ADD,SUBTRACT,DIVIDE OR MULTIPLY":INPUT A$
40 IF A$ = "ADD" THEN GOTO 120
50 IF A$ = "SUBTRACT" THEN GOTO 170
60 IF A$ = "DIVIDE" THEN GOTO 220
70 IF A$ = "MULTIPLY" THEN GOTO 270
120 PRINT "TELL ME THE NUMBER TO ADD"
130 PRINT "NUMBER ONE":INPUT B
140 PRINT "NUMBER TWO":INPUT C
150 D = B+C
160 PRINT "THE ADDITION IS "; D
165 GOTO 10
170 PRINT "TELL ME THE NUMBER TO SUBTRACT"
180 PRINT "NUMBER ONE":INPUT E
190 PRINT "NUMBER TWO":INPUT F
200 G = E-F
210 PRINT "THE SUBTRACTION IS "; G
215 GOTO 10
220 PRINT "TELL ME THE NUMBER TO DIVIDE"
230 PRINT "NUMBER ONE":INPUT H
240 PRINT "NUMBER TWO":INPUT I
250 L = H/I
260 PRINT "THE DIVISION IS "; L
265 GOTO 10
270 PRINT "TELL ME THE NUMBER TO MULTIPLY"
280 PRINT "NUMBER ONE":INPUT M
290 PRINT "NUMBER TWO":INPUT N
300 O = M*N
310 PRINT "THE MULTIPLY IS "; O
315 GOTO 10
320 END
Enjoy!
APPLE ][ CALCULATOR PROGRAMMED BY TOOLKITMAN
May 21, 2016 - 8:40pm
#1
APPLE ][ CALCULATOR PROGRAMMED BY TOOLKITMAN
I have made a little modification to the waiting time:
5 SPEED = 150
10 PRINT "APPLE ][ CALCULATOR 1.1 BY MATTEO TREVISAN"
20 HOME
30 PRINT "DO YOU WANT TO ADD,SUBTRACT,DIVIDE OR MULTIPLY":INPUT A$
40 IF A$ = "ADD" THEN GOTO 120
50 IF A$ = "SUBTRACT" THEN GOTO 170
60 IF A$ = "DIVIDE" THEN GOTO 220
70 IF A$ = "MULTIPLY" THEN GOTO 270
120 PRINT "TELL ME THE NUMBER TO ADD"
130 PRINT "NUMBER ONE":INPUT B
140 PRINT "NUMBER TWO":INPUT C
150 D = B+C
160 PRINT "THE ADDITION IS "; D
161 FOR K = 1 TO 2000
162 NEXT K
165 GOTO 10
170 PRINT "TELL ME THE NUMBER TO SUBTRACT"
180 PRINT "NUMBER ONE":INPUT E
190 PRINT "NUMBER TWO":INPUT F
200 G = E-F
210 PRINT "THE SUBTRACTION IS "; G
211 FOR K = 1 TO 2000
212 NEXT K
215 GOTO 10
220 PRINT "TELL ME THE NUMBER TO DIVIDE"
230 PRINT "NUMBER ONE":INPUT H
240 PRINT "NUMBER TWO":INPUT I
250 L = H/I
260 PRINT "THE DIVISION IS "; L
261 FOR K = 1 TO 2000
262 NEXT K
265 GOTO 10
270 PRINT "TELL ME THE NUMBER TO MULTIPLY"
280 PRINT "NUMBER ONE":INPUT M
290 PRINT "NUMBER TWO":INPUT N
300 O = M*N
310 PRINT "THE MULTIPLY IS "; O
311 FOR K = 1 TO 2000
312 NEXT K
315 GOTO 10
320 END
I have added an underlining to the program:
5 SPEED = 150
6 INVERSE
10 PRINT "APPLE ][ CALCULATOR 1.1 BY MATTEO TREVISAN"
20 HOME
30 PRINT "DO YOU WANT TO ADD,SUBTRACT,DIVIDE OR MULTIPLY":INPUT A$
40 IF A$ = "ADD" THEN GOTO 120
50 IF A$ = "SUBTRACT" THEN GOTO 170
60 IF A$ = "DIVIDE" THEN GOTO 220
70 IF A$ = "MULTIPLY" THEN GOTO 270
120 PRINT "TELL ME THE NUMBER TO ADD"
130 PRINT "NUMBER ONE":INPUT B
140 PRINT "NUMBER TWO":INPUT C
150 D = B+C
160 PRINT "THE ADDITION IS "; D
161 FOR K = 1 TO 2000
162 NEXT K
165 GOTO 10
170 PRINT "TELL ME THE NUMBER TO SUBTRACT"
180 PRINT "NUMBER ONE":INPUT E
190 PRINT "NUMBER TWO":INPUT F
200 G = E-F
210 PRINT "THE SUBTRACTION IS "; G
211 FOR K = 1 TO 2000
212 NEXT K
215 GOTO 10
220 PRINT "TELL ME THE NUMBER TO DIVIDE"
230 PRINT "NUMBER ONE":INPUT H
240 PRINT "NUMBER TWO":INPUT I
250 L = H/I
260 PRINT "THE DIVISION IS "; L
261 FOR K = 1 TO 2000
262 NEXT K
265 GOTO 10
270 PRINT "TELL ME THE NUMBER TO MULTIPLY"
280 PRINT "NUMBER ONE":INPUT M
290 PRINT "NUMBER TWO":INPUT N
300 O = M*N
310 PRINT "THE MULTIPLY IS "; O
311 FOR K = 1 TO 2000
312 NEXT K
315 GOTO 10
320 END
I added the capability of calculating square roots (don't worry, this is not a joke program, my modification works).
I know how hard it is to calculate the square root on paper without a calculator.
It requires a LOT of memorization.
I have tried to program using your style except concerning the line numbers.
I was taught they all need to be always apart by about 10 just in case you need to stick something in between there at the last minute.
5 SPEED = 150
6 INVERSE
10 PRINT "APPLE ][ CALCULATOR 1.1 BY MATTEO TREVISAN"
20 HOME
30 PRINT "DO YOU WANT TO ADD,SUBTRACT,DIVIDE,MULTIPLY,OR SQUARE ROOT":INPUT A$
40 IF A$ = "ADD" THEN GOTO 120
50 IF A$ = "SUBTRACT" THEN GOTO 170
60 IF A$ = "DIVIDE" THEN GOTO 220
70 IF A$ = "MULTIPLY" THEN GOTO 270
80 IF A$ = "SQUARE ROOT" THEN GOTO 330
120 PRINT "TELL ME THE NUMBER TO ADD"
130 PRINT "NUMBER ONE":INPUT B
140 PRINT "NUMBER TWO":INPUT C
150 D = B+C
160 PRINT "THE ADDITION IS "; D
161 FOR K = 1 TO 2000
162 NEXT K
165 GOTO 10
170 PRINT "TELL ME THE NUMBER TO SUBTRACT"
180 PRINT "NUMBER ONE":INPUT E
190 PRINT "NUMBER TWO":INPUT F
200 G = E-F
210 PRINT "THE SUBTRACTION IS "; G
211 FOR K = 1 TO 2000
212 NEXT K
215 GOTO 10
220 PRINT "TELL ME THE NUMBER TO DIVIDE"
230 PRINT "NUMBER ONE":INPUT H
240 PRINT "NUMBER TWO":INPUT I
250 L = H/I
260 PRINT "THE DIVISION IS "; L
261 FOR K = 1 TO 2000
262 NEXT K
265 GOTO 10
270 PRINT "TELL ME THE NUMBER TO MULTIPLY"
280 PRINT "NUMBER ONE":INPUT M
290 PRINT "NUMBER TWO":INPUT N
300 O = M*N
310 PRINT "THE MULTIPLY IS "; O
311 FOR K = 1 TO 2000
312 NEXT K
315 GOTO 10
320 REM THIS PART OF THE PROGRAM WAS ADDED BY INSANITOR
330 PRINT "TELL ME THE NUMBER TO SQUARE ROOT"
335 PRINT "NUMBER":INPUT Q
350 PRINT "THE SQUARE ROOT IS ";SQR(Q)
360 FOR K = 1 TO 2000
370 NEXT K
380 GOTO 10
390 END
A BUG fixed when divided by 0 it doesent go anymore to basic:
5 SPEED = 150
6 INVERSE
10 PRINT "APPLE ][ CALCULATOR 1.1 BY MATTEO TREVISAN"
20 HOME
30 PRINT "DO YOU WANT TO ADD,SUBTRACT,DIVIDE OR MULTIPLY":INPUT A$
40 IF A$ = "ADD" THEN GOTO 120
50 IF A$ = "SUBTRACT" THEN GOTO 170
60 IF A$ = "DIVIDE" THEN GOTO 220
70 IF A$ = "MULTIPLY" THEN GOTO 270
120 PRINT "TELL ME THE NUMBER TO ADD"
130 PRINT "NUMBER ONE":INPUT B
140 PRINT "NUMBER TWO":INPUT C
150 D = B+C
160 PRINT "THE ADDITION IS "; D
161 FOR K = 1 TO 2000
162 NEXT K
165 GOTO 10
170 PRINT "TELL ME THE NUMBER TO SUBTRACT"
180 PRINT "NUMBER ONE":INPUT E
190 PRINT "NUMBER TWO":INPUT F
200 G = E-F
210 PRINT "THE SUBTRACTION IS "; G
211 FOR K = 1 TO 2000
212 NEXT K
215 GOTO 10
220 PRINT "TELL ME THE NUMBER TO DIVIDE"
230 PRINT "NUMBER ONE":INPUT H
240 PRINT "NUMBER TWO":INPUT I
241 IF I = 0 THEN GOTO 265
250 L = H/I
260 PRINT "THE DIVISION IS "; L
262 FOR K = 1 TO 2000
263 NEXT K
265 GOTO 10
270 PRINT "TELL ME THE NUMBER TO MULTIPLY"
280 PRINT "NUMBER ONE":INPUT M
290 PRINT "NUMBER TWO":INPUT N
300 O = M*N
310 PRINT "THE MULTIPLY IS "; O
311 FOR K = 1 TO 2000
312 NEXT K
315 GOTO 10
320 END
This is the bug fixed version plus the INSANITOR SQUARE ROOT!
5 SPEED = 150
6 INVERSE
10 PRINT "APPLE ][ CALCULATOR 1.1 BY MATTEO TREVISAN"
20 HOME
30 PRINT "DO YOU WANT TO ADD,SUBTRACT,DIVIDE, MULTIPLY OR SQUARE ROOT":INPUT A$
40 IF A$ = "ADD" THEN GOTO 120
50 IF A$ = "SUBTRACT" THEN GOTO 170
60 IF A$ = "DIVIDE" THEN GOTO 220
70 IF A$ = "MULTIPLY" THEN GOTO 270
80 IF A$ = "SQUARE ROOT" THEN GOTO 330
120 PRINT "TELL ME THE NUMBER TO ADD"
130 PRINT "NUMBER ONE":INPUT B
140 PRINT "NUMBER TWO":INPUT C
150 D = B+C
160 PRINT "THE ADDITION IS "; D
161 FOR K = 1 TO 2000
162 NEXT K
165 GOTO 10
170 PRINT "TELL ME THE NUMBER TO SUBTRACT"
180 PRINT "NUMBER ONE":INPUT E
190 PRINT "NUMBER TWO":INPUT F
200 G = E-F
210 PRINT "THE SUBTRACTION IS "; G
211 FOR K = 1 TO 2000
212 NEXT K
215 GOTO 10
220 PRINT "TELL ME THE NUMBER TO DIVIDE"
230 PRINT "NUMBER ONE":INPUT H
240 PRINT "NUMBER TWO":INPUT I
241 IF I = 0 THEN GOTO 265
250 L = H/I
260 PRINT "THE DIVISION IS "; L
262 FOR K = 1 TO 2000
263 NEXT K
265 GOTO 10
270 PRINT "TELL ME THE NUMBER TO MULTIPLY"
280 PRINT "NUMBER ONE":INPUT M
290 PRINT "NUMBER TWO":INPUT N
300 O = M*N
310 PRINT "THE MULTIPLY IS "; O
311 FOR K = 1 TO 2000
312 NEXT K
315 GOTO 10
320 REM THIS PART OF THE PROGRAM WAS ADDED BY INSANITOR
330 PRINT "TELL ME THE NUMBER TO SQUARE ROOT"
335 PRINT "NUMBER":INPUT Q
350 PRINT "THE SQUARE ROOT IS ";SQR(Q)
360 FOR K = 1 TO 2000
370 NEXT K
380 GOTO 10
390 END
Toolkitman,
I think you should modify this program.
The problem I see is that while it gives you the math answers, if the answer contains a lot of decimal points, then whoever uses this program will not have enough time to write it down before the program says, APPLE ][ CALCULATOR 1.1 BY MATTEO TREVISAN".
I have written a small part of this modification which I have tested to work properly.
It asks the user to press return for the program to go back to the part that says, APPLE ][ CALCULATOR 1.1 BY MATTEO TREVISAN".
To make this modification, you will have to rearrange the line numbers since you have not left any gaps for modifications.
Anyway, I was taught that you should always program the lines by adding 10 to the next, 10,20,30,40, not 1,2,3,4.
If you choose to do this, you will have to do this modification for the subtraction, division, multiplication and square root parts.
So I leave the decision to you.
Here is my suggested modification:
120 PRINT "TELL ME THE NUMBER TO ADD"
121 PRINT "NUMBER ONE":INPUT B
122 PRINT "NUMBER TWO":INPUT C
123 D = B+C
124 PRINT "THE ADDITION IS "; D
126 PRINT "PRESS RETURN ":INPUT S$
127 IF S$="" THEN GOTO 10
134 FOR K = 1 TO 2000
162 NEXT K
165 GOTO 10
APPLE ][ CALCULATOR BY MATTEO TREVISAN BUG FIXED
I have fixed a bug where if you write a name different than the add,subtract,divide,multiply and square root it will transport you to add, now it restart!
5 SPEED = 150
6 INVERSE
10 PRINT "APPLE ][ CALCULATOR 1.1 BY MATTEO TREVISAN"
20 HOME
30 PRINT "DO YOU WANT TO ADD,SUBTRACT,DIVIDE, MULTIPLY OR SQUARE ROOT":INPUT A$
40 IF A$ = "ADD" THEN GOTO 120
50 IF A$ = "SUBTRACT" THEN GOTO 170
60 IF A$ = "DIVIDE" THEN GOTO 220
70 IF A$ = "MULTIPLY" THEN GOTO 270
80 IF A$ = "SQUARE ROOT" THEN GOTO 330
90 IF A$ <> "ADD" THEN GOTO 10
91 IF A$ <> "SUBTRACT" THEN GOTO 10
92 IF A$ <> "DIVIDE" THEN GOTO 10
93 IF A$ <> "MULTIPLY" THEN GOTO 10
94 IF A$ <> "SQUARE ROOT" THEN GOTO 10
120 PRINT "TELL ME THE NUMBER TO ADD"
130 PRINT "NUMBER ONE":INPUT B
140 PRINT "NUMBER TWO":INPUT C
150 D = B+C
160 PRINT "THE ADDITION IS "; D
161 FOR K = 1 TO 2000
162 NEXT K
165 GOTO 10
170 PRINT "TELL ME THE NUMBER TO SUBTRACT"
180 PRINT "NUMBER ONE":INPUT E
190 PRINT "NUMBER TWO":INPUT F
200 G = E-F
210 PRINT "THE SUBTRACTION IS "; G
211 FOR K = 1 TO 2000
212 NEXT K
215 GOTO 10
220 PRINT "TELL ME THE NUMBER TO DIVIDE"
230 PRINT "NUMBER ONE":INPUT H
240 PRINT "NUMBER TWO":INPUT I
241 IF I = 0 THEN GOTO 265
250 L = H/I
260 PRINT "THE DIVISION IS "; L
262 FOR K = 1 TO 2000
263 NEXT K
265 GOTO 10
270 PRINT "TELL ME THE NUMBER TO MULTIPLY"
280 PRINT "NUMBER ONE":INPUT M
290 PRINT "NUMBER TWO":INPUT N
300 O = M*N
310 PRINT "THE MULTIPLY IS "; O
311 FOR K = 1 TO 2000
312 NEXT K
315 GOTO 10
320 REM THIS PART OF THE PROGRAM WAS ADDED BY INSANITOR
330 PRINT "TELL ME THE NUMBER TO SQUARE ROOT"
335 PRINT "NUMBER":INPUT Q
350 PRINT "THE SQUARE ROOT IS ";SQR(Q)
360 FOR K = 1 TO 2000
370 NEXT K
380 GOTO 10
390 END
FOR INSANITOR:
if you want to have more time to see the numbers you have only to modifiy this string 360 FOR K = 1 TO 2000, example with a value of 5000.
Enjoy!
there is also an Easter Egg find it!
5 SPEED = 150
6 INVERSE
10 PRINT "APPLE ][ CALCULATOR 1.1 BY MATTEO TREVISAN"
20 HOME
30 PRINT "DO YOU WANT TO ADD,SUBTRACT,DIVIDE, MULTIPLY OR SQUARE ROOT":INPUT A$
40 IF A$ = "ADD" THEN GOTO 120
50 IF A$ = "SUBTRACT" THEN GOTO 170
60 IF A$ = "DIVIDE" THEN GOTO 220
70 IF A$ = "MULTIPLY" THEN GOTO 270
80 IF A$ = "SQUARE ROOT" THEN GOTO 330
81 IF A$ = "PUDDING" THEN PRINT "DO YOU WANT SOME PUDDING?"
90 IF A$ <> "ADD" THEN GOTO 10
91 IF A$ <> "SUBTRACT" THEN GOTO 10
92 IF A$ <> "DIVIDE" THEN GOTO 10
93 IF A$ <> "MULTIPLY" THEN GOTO 10
94 IF A$ <> "SQUARE ROOT" THEN GOTO 10
120 PRINT "TELL ME THE NUMBER TO ADD"
130 PRINT "NUMBER ONE":INPUT B
140 PRINT "NUMBER TWO":INPUT C
150 D = B+C
160 PRINT "THE ADDITION IS "; D
161 FOR K = 1 TO 5000
162 NEXT K
165 GOTO 10
170 PRINT "TELL ME THE NUMBER TO SUBTRACT"
180 PRINT "NUMBER ONE":INPUT E
190 PRINT "NUMBER TWO":INPUT F
200 G = E-F
210 PRINT "THE SUBTRACTION IS "; G
211 FOR K = 1 TO 5000
212 NEXT K
215 GOTO 10
220 PRINT "TELL ME THE NUMBER TO DIVIDE"
230 PRINT "NUMBER ONE":INPUT H
240 PRINT "NUMBER TWO":INPUT I
241 IF I = 0 THEN GOTO 265
250 L = H/I
260 PRINT "THE DIVISION IS "; L
262 FOR K = 1 TO 5000
263 NEXT K
265 GOTO 10
270 PRINT "TELL ME THE NUMBER TO MULTIPLY"
280 PRINT "NUMBER ONE":INPUT M
290 PRINT "NUMBER TWO":INPUT N
300 O = M*N
310 PRINT "THE MULTIPLY IS "; O
311 FOR K = 1 TO 5000
312 NEXT K
315 GOTO 10
320 REM THIS PART OF THE PROGRAM WAS ADDED BY INSANITOR
330 PRINT "TELL ME THE NUMBER TO SQUARE ROOT"
335 PRINT "NUMBER":INPUT Q
350 PRINT "THE SQUARE ROOT IS ";SQR(Q)
360 FOR K = 1 TO 5000
370 NEXT K
380 GOTO 10
390 END
I only made a suggestion.
If you use any real calculator, it will display the answer until you press another key.
Anyway, it's your program, not mine.
This is an automated calculator .
I have added the EXPONENTIATION MATH AND PERCENTAGE FORMULA:
5 SPEED = 150
6 INVERSE
10 PRINT "APPLE ][ CALCULATOR 1.1 BY MATTEO TREVISAN"
20 HOME
30 PRINT "DO YOU WANT TO ADD,SUBTRACT,DIVIDE, MULTIPLY, SQUARE ROOT, EXPONENTIATION OR PERCENTAGE":INPUT A$
40 IF A$ = "ADD" THEN GOTO 120
50 IF A$ = "SUBTRACT" THEN GOTO 170
60 IF A$ = "DIVIDE" THEN GOTO 220
70 IF A$ = "MULTIPLY" THEN GOTO 270
80 IF A$ = "SQUARE ROOT" THEN GOTO 330
81 IF A$ = "EXPONENTIATION" THEN GOTO 390
82 IF A$ = "PERCENTAGE" THEN GOTO 470
83 IF A$ = "PUDDING" THEN PRINT "DO YOU WANT SOME PUDDING?"
90 IF A$ <> "ADD" THEN GOTO 10
91 IF A$ <> "SUBTRACT" THEN GOTO 10
92 IF A$ <> "DIVIDE" THEN GOTO 10
93 IF A$ <> "MULTIPLY" THEN GOTO 10
94 IF A$ <> "SQUARE ROOT" THEN GOTO 10
95 IF A$ <> "EXPONENTIATION" THEN GOTO 10
96 IF A$ <> "PERCENTAGE" THEN GOTO 10
120 PRINT "TELL ME THE NUMBER TO ADD"
130 PRINT "NUMBER ONE":INPUT B
140 PRINT "NUMBER TWO":INPUT C
150 D = B+C
160 PRINT "THE ADDITION IS "; D
161 FOR K = 1 TO 5000
162 NEXT K
165 GOTO 10
170 PRINT "TELL ME THE NUMBER TO SUBTRACT"
180 PRINT "NUMBER ONE":INPUT E
190 PRINT "NUMBER TWO":INPUT F
200 G = E-F
210 PRINT "THE SUBTRACTION IS "; G
211 FOR K = 1 TO 5000
212 NEXT K
215 GOTO 10
220 PRINT "TELL ME THE NUMBER TO DIVIDE"
230 PRINT "NUMBER ONE":INPUT H
240 PRINT "NUMBER TWO":INPUT I
241 IF I = 0 THEN GOTO 265
250 L = H/I
260 PRINT "THE DIVISION IS "; L
262 FOR K = 1 TO 5000
263 NEXT K
265 GOTO 10
270 PRINT "TELL ME THE NUMBER TO MULTIPLY"
280 PRINT "NUMBER ONE":INPUT M
290 PRINT "NUMBER TWO":INPUT N
300 O = M*N
310 PRINT "THE MULTIPLY IS "; O
311 FOR K = 1 TO 5000
312 NEXT K
315 GOTO 10
320 REM THIS PART OF THE PROGRAM WAS ADDED BY INSANITOR
330 PRINT "TELL ME THE NUMBER TO SQUARE ROOT"
335 PRINT "NUMBER":INPUT Q
350 PRINT "THE SQUARE ROOT IS ";SQR(Q)
360 FOR K = 1 TO 5000
370 NEXT K
380 GOTO 10
390 PRINT "TELL ME THE NUMBER YOU WANT THE EXPONENTIATION"
400 PRINT "NUMBER ONE":INPUT P
410 PRINT "NUMBER TWO":INPUT Q
420 R = P^Q
430 PRINT "THE EXPONENTIATION IS "; R
440 FOR K = 1 TO 5000
450 NEXT K
460 GOTO 10
470 PRINT "TELL ME THE PERCENTAGE TO CALCULATE"
480 PRINT "NUMBER ONE %":INPUT S
490 PRINT "NUMBER TWO":INPUT T
500 U = (S/100)*T
510 PRINT "THE PERCENTAGE IS "; U
520 FOR K = 1 TO 5000
530 NEXT K
540 GOTO 10
550 END
It seems you may not like suggestions, but I have never been accused of being awfully tactful, so here goes.
As it is now if you type in PUDDING, you will go to addition, so keeping that 'functionality' and returning to the start on anything other than 'PUDDING" or one of the valid operations, you can clean up the first few lines like this:
5 SPEED = 150
6 INVERSE
10 PRINT "APPLE ][ CALCULATOR 1.1 BY MATTEO TREVISAN"
20 HOME
30 PRINT "DO YOU WANT TO ADD,SUBTRACT,DIVIDE, MULTIPLY, SQUARE ROOT, EXPONENTIATION OR PERCENTAGE":INPUT A$
40 IF A$ = "ADD" THEN GOTO 120
50 IF A$ = "SUBTRACT" THEN GOTO 170
60 IF A$ = "DIVIDE" THEN GOTO 220
70 IF A$ = "MULTIPLY" THEN GOTO 270
80 IF A$ = "SQUARE ROOT" THEN GOTO 330
81 IF A$ = "EXPONENTIATION" THEN GOTO 390
82 IF A$ = "PERCENTAGE" THEN GOTO 470
83 IF A$ = "PUDDING" THEN PRINT "DO YOU WANT SOME PUDDING?" : GOT0 120
90 GOTO 10
120 PRINT "TELL ME THE NUMBER TO ADD"
....
And save yourself 6 lines of code.
Do some screen management and place the result in a location that you do not overwrite.
Better still use an accumulator and operand registers (just a small array), that way a previous result can be used in a subsequent calculation.
Even better still, write it using RPN (Reverse Polish Notation) and a stack (yet again just another simple array) so that you can do very complex calculations simply and without the use of parenthesis.
Here is how I would do the simple calculator you have written. I have not tested this yet:
5 SPEED = 150
6 INVERSE
10 PRINT "APPLE ][ CALCULATOR 1.1 BY MATTEO TREVISAN"
20 HOME
30 PRINT "DO YOU WANT TO (AD)D, (SU)BTRACT, (DI)VIDE, (MU)LTIPLY, (SQ)UARE ROOT, (EX)PONENTIATION OR (PE)RCENTAGE":INPUT A$
40 IF A$ = "AD" THEN GOSUB 120
50 IF A$ = "SU" THEN GOSUB 170
60 IF A$ = "DI" THEN GOSUB 220
70 IF A$ = "MU" THEN GOSUB 270
80 IF A$ = "SQ" THEN GOSUB 330
81 IF A$ = "EX" THEN GOSUB 390
82 IF A$ = "PE" THEN GOSUB 470
83 IF A$ = "PUDDING" THEN PRINT "PUDDING! ARE YOU SERIOUS?"
90 IF A$ <> "OK" THEN PRINT "UNKOWN OPERATION OR FUNCTION. TRY AGAIN" : GOSUB 1000
100 GOTO 10
120 PRINT "ADDITION"
130 PRINT "NUMBER ONE":INPUT A
140 PRINT "NUMBER TWO":INPUT B
150 C = A+B
160 PRINT A;" PLUS ";B;" IS "; C
161 GOSUB 1000
165 A$ = "OK" : RETURN
170 PRINT "SUBTRACTION"
180 PRINT "NUMBER ONE":INPUT A
190 PRINT "NUMBER TWO":INPUT B
200 C = A-B
210 PRINT A;" MINUS ";B;" IS "; C
211 GOSUB 1000
215 A$ = "OK" : RETURN
220 PRINT "DIVISION"
230 PRINT "NUMERATOR":INPUT A
240 PRINT "DENOMINATOR":INPUT B
241 IF B = 0 THEN PRINT "YOU CANNOT DIVIDE BY ZERO" : GOTO 262
250 C = A/B
260 PRINT A;"DIVIDED BY ";B;" IS "; C
262 GOSUB 1000
265 A$ = "OK" : RETURN
270 PRINT "MULTIPLICATION"
280 PRINT "NUMBER ONE":INPUT A
290 PRINT "NUMBER TWO":INPUT B
300 C = A*B
310 PRINT A;" TIMES ";B;" IS "; C
311 GOSUB 1000
315 A$ = "OK" : RETURN
320 REM THIS PART OF THE PROGRAM WAS ADDED BY INSANITOR
330 PRINT "SQUARE ROOT"
335 PRINT "NUMBER":INPUT A
350 PRINT "THE SQUARE ROOT OF ";A;" IS ";SQR(A)
360 GOSUB 1000
380 A$ = "OK" : RETURN
390 PRINT "EXPONENTIATION"
400 PRINT "BASE":INPUT A
410 PRINT "EXPONENT":INPUT B
420 C = A^B
430 PRINT A;" TO THE ";B;" POWER IS "; C
440 GOSUB 1000
460 A$ = "OK" : RETURN
470 PRINT "PERCENTAGE"
480 PRINT "THE % YOU WANT":INPUT A
490 PRINT "OF WHAT NUMBER":INPUT B
500 C = (A/100)*B
510 PRINT A;" PERCENT OF";B;" IS "; C
520 GOSUB 1000
540 A$ = "OK" : RETURN
1000 FOR K = 1 TO 5000
1010 NEXT K
1020 RETURN
10000 END
What use is a calculator that clears its own display?
Make sense an Operating System that after million of dollars of Software installed get a blue screen of death and there is nothing to do then reinstall everything????
Better a Calculator That clean his screen from itself but leave your time to write down a note!
And the solution to your problem is to type PAUSE OR BREAK on the keyboard.
ENJOY! :macos:
For BillO:
your corrections to my program works fine, i like the way you move, act, reason!!
Here you can download a .dsk disk image with your modified version!
https://archive.org/download/APPLESIMPLIFIEDCALCULATORBYM.T.BillO
That's like saying:
"Better a nuclear disaster that kills everybody on this planet but leave you time to say your prayers!"
And the solution to your problem is to push the button.
ENJOY! :macos:
Thanks for the disk image. I'll download it and try it out when I get a chance. I've been hankering for some quality time with my Apple II and I've had further ideas on how to make this a useful little utility. I'll get back on this. Right now my ADTPro server has lost it's WIFI I/F, so all transfers are sneaker-net.
I also want the create an RPN calculator of enhanced capability to do real math. The RPN concept is very appealing for this.
Okay, I had chance to get to it this morning.
The following program is much improved and has these new features
* Result is displayed until user takes action
* Result can be retained for further calculations
* Single key function selection
* Improved formatting of display
* Result negation is facilitated for further calculations
Operation should be fairly intuitive, except the following.
Once the result of an operation is displayed, you will have the opportunity to retain that result for teh next calculation by hitting the (R) key. any other key will clear the result and continue.
If you choose to retain a result for further calculations, that result will be presented in brackets as the default amount for the first (or only) number for the next operation. You then have 4 options:
1) Hitting return will use the displayed value in the current operation.
2) Entering a minus sign (-) will negate that value for use in the current operation.
3) Entering another number will replace the default value with the entered number.
4) Entering anything else will use zero as the value.
Try it out and let me know if there are any problems. I personally will make no further improvements or additions to this program. My next effort will be the RPN calculator.
10 HOME
20 M$ = "FIRST NUMBER "
30 PRINT "APPLE ][ CALCULATOR 2"
40 PRINT : PRINT "FUNCTION": PRINT
50 PRINT " +"
60 PRINT " -"
70 PRINT " *"
80 PRINT " /"
90 PRINT " %"
100 PRINT " S (SQUARE ROOT)"
110 PRINT " E (EXPONENTIATE)"
120 PRINT : PRINT " ?";: GET A$
130 PRINT : PRINT
140 IF A$ = "+" THEN GOSUB 240
150 IF A$ = "-" THEN GOSUB 310
160 IF A$ = "/" THEN GOSUB 380
170 IF A$ = "*" THEN GOSUB 460
180 IF A$ = "S" THEN GOSUB 530
190 IF A$ = "E" THEN GOSUB 590
200 IF A$ = "%" THEN GOSUB 660
210 IF A$ = "PUDDING" THEN PRINT "PUDDING! ARE YOU SERIOUS?"
220 IF A$ < > "OK" THEN PRINT : PRINT "UNKOWN OPERATION OR FUNCTION. TRY AGAIN": GOSUB 780
230 GOTO 10
240 PRINT "ADDITION": PRINT
250 GOSUB 800
260 INPUT "ENTER 2ND NUMBER ?";B
270 C = A + B
280 PRINT : PRINT A;" PLUS ";B;" IS ";C
290 GOSUB 730
300 A$ = "OK": RETURN
310 PRINT "SUBTRACTION": PRINT
320 GOSUB 800
330 INPUT "ENTER 2ND NUMBER ?";B
340 C = A - B
350 PRINT : PRINT A;" MINUS ";B;" IS ";C
360 GOSUB 730
370 A$ = "OK": RETURN
380 PRINT "DIVISION": PRINT
390 M$ = "NUMERATOR ": GOSUB 800
400 INPUT "ENTER DENOMINATOR ?";B
410 IF B = 0 THEN PRINT "YOU CANNOT DIVIDE BY ZERO": RETURN
420 C = A / B
430 PRINT : PRINT A;" DIVIDED BY ";B;" IS ";C
440 GOSUB 730
450 A$ = "OK": RETURN
460 PRINT "MULTIPLICATION": PRINT
470 GOSUB 800
480 INPUT "ENTER 2ND NUMBER ?";B
490 C = A * B
500 PRINT A;" TIMES ";B;" IS ";C
510 GOSUB 730
520 A$ = "OK": RETURN
530 PRINT "SQUARE ROOT": PRINT
540 M$ = "NUMBER ": GOSUB 800
550 C = SQR
560 PRINT : PRINT "THE SQUARE ROOT OF ";A;" IS ";C
570 GOSUB 730
580 A$ = "OK": RETURN
590 PRINT "EXPONENTIATION": PRINT
600 M$ = "BASE ": GOSUB 800
610 INPUT "ENTER EXPONENT ?";B
620 C = A ^ B
630 PRINT : PRINT A;" TO THE ";B;" POWER IS ";C
640 GOSUB 730
650 A$ = "OK": RETURN
660 PRINT "PERCENTAGE": PRINT
670 M$="THE % YOU WANT ": GOSUB 800
680 INPUT "OF WHAT AMOUNT ?";B
690 C = (A / 100) * B
700 PRINT : PRINT A;" PERCENT OF ";B;" IS ";C
710 GOSUB 730
720 A$ = "OK": RETURN
730 PRINT : PRINT "PRESS (R) TO RETAIN THIS VALUE"
740 PRINT "OR ANY OTHER KEY TO CLEAR AND"
750 PRINT "CONTINUE";: GET X$
760 D = 0: IF X$ = "R" THEN D = C
770 RETURN
780 FOR K = 1 TO 2000
790 NEXT K : RETURN
800 PRINT : PRINT "ENTER ";M$;
810 IF D < > 0 THEN PRINT "(";D;") ";
820 INPUT E$
830 IF E$ = "" THEN A = D: RETURN
835 IF E$ = "-" THEN A = -D: RETURN
840 A = VAL (E$): RETURN
Nice Bill,
here you can download the .dsk image : ).
DOWNLOAD HERE
Thanks Toolkitman.
I actually fixed my network problems so can access my vintage system server now and no longer need images made for me.
Thanks anyway.