Sharp EL-9300C Program Bank
Time for some retro-programming.
Random Integers: pickint
REAL Mode
Print "Pick n integers"
Print "(a,b)"
Input a
Input b
Input n
Label loop
num=ipart ((b-a+1)random)
Print num
Wait
n=n-1
If n≠0 Goto loop
Example: Pick 5 integers from 100 to 999.
a = 100, b = 999, n = 5
Results: num = 487, 834, 587, 486, 617 (results will vary)
Binary Integer Arithmetic: binbool
NBASE Mode
ClrT
0→bin
Rem switch to binary
Rem must use global
Print "binary int 1"
Input X
Print "binary int 2"
Input Y
ClrT
Print "and (1/4)"
Q=X and Y
Print Q
Print "or (2/4)"
R=X or Y
Print R
Wait
Print "nand (3/4)"
S=not(X and Y)
Wait
Print "xor (4/4)"
T = X xor Y
Print T
End
Example:
X = 111011
Y = 000111
Results:
(and)
Q = 0000 0000 0000 0011
(or)
R = 0000 0000 0001 1111
(nand)
S = 1111 1111 1111 1100
(xor)
T = 0000 0000 0001 1100
Distance Between Two Spheres: distsph
REAL Mode
ClrT
Print "Distance between"
Print "two spheres"
Print "Sphere 1"
Rem 2ndF number in test
Input x₁
Input y₁
Input z₁
Input r₁
Print "Sphere 2"
Input x₂
Input y₂
Input z₂
Input r₂
dist=√((x₁-x₂)²+(y₁-y₂)²+(z₁+z₂)²)-r₁-r₂
Print "Distance="
Print dist
End
Example:
Sphere 1: (80, 0, 60), radius 5
Sphere 2: (14, -5, 20), radius 10
Result: 62.3369252
Draw Lines: drawlines
REAL Mode
Rem 2ndF number
Rem A and B are orig pts.
ClrG
Range -10,10,1,-10,10,1
Print "Draw a polygon"
Print "A = x₀"
Input A
Print "B = y₀"
Input B
xa=A
ya=B
Plot A,B
Label loop1
Print "Orig. (A,B)"
Input xi
Input yi
t=0
Lable loop2
x=(1-t)*xa+t*xi
y=(1-t)*ya+t*yi
Plot x,y
t=t+.02
If t<0 Goto loop2
xa=xi
ya=yi
Print "0=no 1=yes"
Input more
If more≠0 Goto loop1
DispG
To return to the original point, set xi = A ([ALPHA] [2ndF] A) and yi = B ([ALPHA] [2ndF] B).
Example:
Draw a polygon of points (0,8), (3,5), (0,-3), (-2, 3).
Eddie
All original content copyright, © 2011-2023. Edward Shore. Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited. This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.