Question

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.

Was it helpful?

Solution

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

OTHER TIPS

Generally, when declaring variables on the calculator, you want to stick to one or two characters, if possible. Up to five do work, but it is common practice to use less. If you want the user to know what the inputs are, try this:

:DISP "XONE:"
:PROMPT A
:DISP "YONE:"
:PROMPT B
:DISP "XTWO:"
:PROMPT C
:DISP "YTWO:"
:PROMPT D
:((A+C)/2)->X
:((B+D)/2)->Y
:DISP X,Y

Happy Coding!

You are correct, normal variables are limited in length to a single character; however, multiple character variable names can be used in other aspects of TI-Basic programming.

List Variables

List variables can be named using between between 1 and 5 characters, or using the 6 predefined list variables (L1-L6).

{1,2,3,4→ALIST

System Variables

System variables are found by pressing the VARS key on you calculator. They consists of statistical, table and, graph variables that generally consist of 3 or 4 characters. Examples of these variables include Xmin, Xmax, Ymin, Ymax, TblStart and, TblInput. Values can be stored to these variables in the same manner as normal variables.

10→Xmin

10→Xmax

Finance Variables

Finance variables function similarly to system variables. They are a set of predefined variables with multi-character names. The primary difference being that they all pertain to finance in some manner. These variables are accessed by pressing APPS, 1, Right Arrow. Examples of include I%, PV and, PMT.

10→I%

10→PV

10→PMT

This answer is based entirely off a TI-83 Plus calculator. As far as I know, this should not be an issue, but any inconstancy can be put down to this.

I like to use input for this:

Disp "(A,B)(C,D)
Input "A:",A
Input "B:",B
Input "C:",C
Input "D:",D

I have a program with this function that i will try to upload later today.

EDIT: Uploaded and available for download here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top