Sunday, May 7, 2023

TI-84 Plus CE: Drawing a Balance Scale and an Updated High Low Game

TI-84 Plus CE:   Drawing a Balance Scale and an Updated High Low Game



Drawing a Scale



The program DSCALE draws a balance scale given two weights:  one placed on the left side (A) and one on the right side.  The length of the bar, which is measured from the center to one of the weights can be set by the user.   Assume that the length is equal on both sides.





The scale in this program is not meant to bend more than 45°.   The program will not draw the scale if the bend is greater than 45°.  


DSCALE was programmed with a TI-84 Plus CE, but can be programmed on a monochrome calculator with the color commands taken out.


The program repeats for different weights at the user's choice.  



TI-84 Plus CE Program:   DSCALE



Degree:Func:FnOff 

Disp "BALANCE SCALE"

Disp "LENGTH-CENTER?"

Prompt L

4→W

Lbl 1

ClrHome

Disp "LENGTH-CENTER:",L,""

Input "LEFT WEIGHT? ",A

Input "RIGHT WEIGHT? ",B

(B-A)/2→D

abs(tan^-1((B-A)/L))→θ

W*(B-A)/L→S

If θ>45:Then:Disp "CANNOT DRAW":Goto 2:End

­-W-1→Xmin:W+1→Xmax:1→Xscl

­-W-1→Ymin:W+1→Ymax:1→Yscl

AxesOff:LabelOff

ClrDraw

Line(0,W,0,-­W,ORANGE)

Line(-­.5,W,.5,W,BROWN)

Line(­-1,­-W,1,­-W,BROWN)

Line(­-.5,W,-­W,S,LTGRAY)

Line(.5,W,W,­-S,LTGRAY)

Line(­-W,S,W,­-S,BLACK)

Lbl 2

Pause 

Menu("AGAIN?","YES",1,"NO",0)

Lbl 0

Disp "THANK YOU"







Updating a Game



The program HILODS is the classic high-low guessing game, but instead of text, it draws a balance scale to indicate whether you are higher and lower from the target number.  You work with the left weight (A), with the goal of balancing with the right weight (B).  The right weight is set with a random integer from 10 to 99.  


The game has three difficulty levels:  easy (25 guesses), medium (15 guesses), and hard (10 guesses).



TI-84 Plus CE Program:   HILODS


Degree:Func:FnOff 

Disp "HIGH-LOW GAME"

AxesOff:LabelOff

100→L

randInt(10,99)→B

4→W

­-W-1→Xmin:W+1→Xmax:1→Xscl

­-W-1→Ymin:W+1→Ymax:1→Yscl

Menu("DIFFICULTY LEVEL","EASY",10,"MEDIUM",11,"HARD",12)

Lbl 10:25→C:Goto 20

Lbl 11:15→C:Goto 20

Lbl 12:10→C:Goto 20

Lbl 20

Disp toString(C)+" GUESSES"

Disp "BETWEEN 10 AND 99"

C→N


Lbl 1

ClrHome

Disp "GUESSES LEFT: "+toString(C)

Disp "{10,99}"

Input "GUESS? ",A

(B-A)/2→D

W*(B-A)/L→S

ClrDraw

Line(0,W,0,-­W,ORANGE)

Line(-­.5,W,.5,W,BROWN)

Line(­-1,­-W,1,­-W,BROWN)

Line(­-.5,W,-­W,S,LTGRAY)

Line(.5,W,W,­-S,LTGRAY)

Line(­-W,S,W,­-S,BLACK)

Pause 

C-1→C

If A=B:Goto 9

If C=0:Goto 8

Goto 1


Lbl 8

ClrHome

Disp "THE NUMBER IS "+toString(B)

Disp toString(abs(A-B))+" AWAY"

Disp "BETTER LUCK NEXT TIME"

Stop



Lbl 9

ClrHome

Disp "THE NUMBER IS "+toString(A)

Disp "YOU WIN!"

Disp "NUMBER OF GUESSES: "+toString(N-C)

Stop







Download both programs here (as a zip file):  https://drive.google.com/file/d/1hJwyqSZJ-aCQ36Wh2cCfMVy6BpAzmmPZ/view?usp=share_link



Enjoy,


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. 


TI 84 Plus CE: Consolidated Debts

TI 84 Plus CE: Consolidated Debts   Disclaimer: This blog is for informational and academic purposes only. Financial decisions are your ...