I am trying to create a simple BASIC program for my TI-84 that will calculate the midpoint of two given points. This is my current code below, which produces an error upon trying to run the program:
:Prompt XONE,YONE,XTWO,YTWO
:((XONE+YONE)/2)->X
:((XTWO+YTWO)/2)->Y
:Disp X,Y
The reason I suspect it has something to do with my variable naming is because I tried running the same program, except I named the variables A,B,C, and D, instead of what you see above, and that ran fine.
Some variants of TI BASIC (such as those that ship with the 68000-CPU-based devices) allow for longer variable names but the variant that ships with the TI-84 calculator only allows the variables A
through Z
and theta. See here for more detail.
Hence, for those, you cannot use variables like XONE
as you have done in your code.
In any case, your midpoint calculation is fundamentally wrong. You currently have it averaging XONE
and YONE
to get the midpoint on the X-axis, whereas you should be averaging XONE
and XTWO
(that's of course ignoring the limitations already mentioned about allowed variable names).
In other words (assuming the variables were valid for your calculator, which they're not), it would be:
:((XONE+XTWO)/2)->X
:((YONE+YTWO)/2)->Y
With both those changes (fixing the midpoint calculation and only using allowed variable names), that would be something like:
:DISPLAY "X1:"
:PROMPT A
:DISPLAY "Y1:"
:PROMPT B
:DISPLAY "X2:"
:PROMPT C
:DISPLAY "Y2:"
:PROMPT D
:((A+C)/2)->E
:((B+D)/2)->F
:DISP E
:DISP F
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With