Вы находитесь на странице: 1из 2

First Introduction to Writing Programs For The TI83 Calculator

Our very first program is just an extremely simple job that will get us familiar with how to program.
We want the calculator to ask us for a number and then display what the square of that number is.

In human language, the program is this...


Step 1: Ask the user for a number and then store that number as “X”
Step 2: Display what X2 is

The calculator uses special language that we as programmers need to learn. The steps above, when
written in calculator language look like this...

: Input X
: Disp X2

Before we can enter this program into the calculator we first need to give the program a name.
Let’s call that name “SQUARE”. Now we’re ready to write the program into our calculators.

- Press the PRGM key


- Select “NEW”
- Enter the name of the program (in this case, “SQUARE”)
- Enter the program shown above using the calculator language. To enter the commands “Input”
and “Disp”, you need to press the PRGM key and then select “I/O” while you are writing your
program.
- When you are finished entering all the steps of the program, press the yellow key and then the
MODE key (in order to select “QUIT”).

Congratulations. You’ve written your first program. To run the program, press PRGM, and under
EXEC select the name of the program you want to run (which in this case will be “SQUARE”.)

Now, let’s write a program that’s actually useful.... one that calculates the distance between two
points. Here is what the program looks like in calculator language. (I’ve given the program the
name “DIST”.) You just need to enter the text shown in bold type.

PROGRAM DIST:
: Input “X1=”,X (The text inside the quotation marks will be displayed by the calculator
: Input “Y1=”,Y when it prompts the user for input. This will help the people who run
: Input “X2=”,A our program know which coordinate they’re supposed to enter.)
: Input “Y2=”,B
: Disp “DISTANCE IS...”, √((X-A)2+(Y-B)2)

Enter this program into your calculator. Note that the equal sign (=) is not printed on the
keyboard like the letters are, but it’s not too hard to find if you know where to look. When you’re at
the place in the program where you want to type it in, press the yellow key and then the MATH
key. That will take you to the “TEST” menu and there you can select the equal sign.

fn:drh041013a Academy for Math, Engineering and Science - Salt Lake City, UT Page 1 of 2
Programming on the TI83 Calculator - Continued

You should now have a program named “DIST” on your calculator that will tell you the distance
between any two points when you enter their X,Y coordinates. Now let’s write a new program....
one that will calculate the slope of the line that connects any two points. One way to do this would
be to write a program like the following. (I’ve called this program “SLOPE”.)

PROGRAM:SLOPE
: Input “X1=”,X
: Input “Y1=”,Y
: Input “X2=”,A
: Input “Y2=”,B
: Disp “SLOPE =”,(B-Y)/(A-X)
: Disp “SLOPE FRACTION=”,(B-Y)/(A-X)►Frac (This last line isn’t really necessary but
sometimes it’s nice to display the slope as a fraction rather than as a decimal.) (The command for
►Frac is found by pressing the MATH key and selecting item #1.)

But wait... Before you take the time to type all that into your calculator, notice that the first four
lines of the SLOPE program are exactly the same as the first four lines of the DIST program.
Maybe there’s a way that we can save ourselves some work here. Let’s write a new program that
calls on the DIST program and lets that DIST program do the work of inputting the four variables
that we need. (It’s perfectly OK for one program to call on another one. In fact, that’s a very good
way to do things.) Then our new program can take those X,Y,A, and B values and it can do our
slope calculations for us. I’ll call this new program “SLOPDIST”. It looks like this...

PROGRAM: SLOPDIST
: prgmDIST (this is where our new program calls the DIST program)
: Disp “SLOPE =”,(B-Y)/(A-X)
: Disp “SLOPE FRACTION=”,(B-Y)/(A-X)►Frac

In order to enter that first line there... (“prgmDIST”)... what you need to do right after you create
your new program is to press the PRGM key, use the arrow keys to move over to EXEC, and then
select the program DIST (or whatever it is that you named your distance calculation program).
When we run our new program, it will tell us the distance and then it will tell us what the slope is.

For extra credit:

Create two more programs…

(1) One should ask the user to enter two points on a line and then it should calculate what the both
the slope and the y intercept would be for the line that contains those two points.

(2) The other program can be one of your own choosing… it just needs to be math related. It should
be something that would be useful for you when working problems in this math class.

fn:drh041013a Academy for Math, Engineering and Science - Salt Lake City, UT Page 2 of 2

Вам также может понравиться