Thursday, April 18, 2019

TI-74: Lottery, Solving Linear Equation Script, Escape Velocity Solver

TI-74:  Lottery, Solving Linear Equation Script, Escape Velocity Solver

TI-74 Program:  Lottery

This program collects six random digits from 1 to 63.  The results are stored in an array N.  The dimension pointers of the TI-74 are from 0 to n-1. 

To execute:  RUN 200

Note:  comments (after !) are for notes, and do not need to be typed. 

200 DIM N(5)
202 INPUT "SEED: ";S
204 RANDOMIZE S
210 FOR I=0 TO 5    ! choose random numbers
212 R=INT(RND*63+1)
220 FOR J=0 TO 5   ! check to see if the random number is unique
222 IF R=N(J) THEN 212
224 NEXT J
230 N(I) = R
232 K=K+1
234 PRINT "# "&STR$(K)$": "&STR$(N(I))
236 PAUSE 1.5
240 NEXT I
242 END

TI-74 Program:  Solving Linear Equation Script

This program uses READ and DATA to execute a teaching script.

To execute:  RUN 300

300 FOR I=1 TO 5
302 READ S$  ! string variables have the dollars sign after the name
304 PRINT S$: PAUSE
306 NEXT
310 DATA "To Solve: a*x + b = c"
312 DATA "a*x + b - b = c - b"
314 DATA "a*x = c - b"
316 DATA "(a*x)/a = (c-b)/a"
318 DATA "x = (c-b)/a"
320 END

TI-74 Program:  Escape Velocity Solver

This program is in two stages:
1.  Enter data.  Use M, R, or V to enter data.  When done, press C to solve.
2.  Choose which variable to solve for. 

M = mass of the planet in kg
R = radius of the planet in km
V = escape velocity in km/s

G = Universal Gravitational Constant
= 6.672E-11 m^3/(kg*s^2) = 6.672E-20 km^3/(kg*s^2)

Equation:  V = √(2 * G * M/R)

To execute:  RUN 400

400 M=0:R=0:V=0:G=6.674E-20
402 PRINT "M MASS, R RADIUS, V VEL, CALC":K$=KEY$
406 IF K$="M" THEN 420
408 IF K$="R" THEN 430
410 IF K$="V" THEN 440
412 IF K$ = "C" THEN 450
414 GOTO 402   ! repeats loop if any other key is pressed

420 INPUT "MASS (KG): ";M
422 GOTO 402
430 INPUT "RADIUS (KM): ";R
432 GOTO 402
440 INPUT "VELOCITY (KM/S): ";V
442 GOTO 402
450 PRINT "SOLVER: M,R,V": K$=KEY$

452 IF K$="M" THEN 460
454 IF K$="R" THEN 470
456 IF K$="V" THEN 480
458 GOTO 450

460 M=V^2*R/(2*G)
462 PRINT "MASS =";M;" KG": PAUSE
464 GOTO 490
470 R=2*G*M/V^2
472 PRINT "RADIUS =";R;" KM": PAUSE
474 GOTO 490
480 V=SQR(2*G*M/R)   ! SQR is √
482 PRINT "VELOCITY =";V;" KM/S": PAUSE
484 GOTO 490

490 PRINT "AGAIN? Y/N": K$=KEY$
492 IF K$="Y" THEN 402
494 IF K$="N" THEN END
496 GOTO 490

Examples: 

Solve for V:   M: 5.9724E24 kg, R:  6374 km,  Result: V ≈ 11.178 KM/S
*Escape Velocity for Earth

Solve for M:  R: 5800 km, V: 16 km/s,  Result:  M ≈ 1.112E25 kg

Solve for R:  M: 3.8E24 kg, V: 22 km/s, Result:  R ≈ 1048.0148 km

Eddie

All original content copyright, © 2011-2019.  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.