If you have a program that consists solely of displaying things, and it’s not some kind of thrilling narrative or story, then you have problems.
What you need is input.
So here’s how to do it:
Input X Disp X
Wasn’t that tricky? When you run it, you’ll get a question mark (as in, “Yo! What do you want to input?”) and when you type something in (numbers only, for now), it’ll name the input ‘X’. Then you just ask it to display X.
(Input is in the same menu as Disp, if you’re having trouble finding it. Typing in I then N then P…etcetera, won’t work)
Now let’s do something (somewhat) useful:
Input L #L for length
Input W #W for width
(NOTE: Everything after a # is a comment. Do not type it into the actual program, it’s just me explaining why I wrote a particular line the way it is. So what you should type in is:)
There’ll be a ‘?’. You type in a number (length of rectangle). There’ll be another ‘?’. You type in another number (width of rectangle). It displays the product of the two numbers (area of rectangle).
In terms of function that ends our lesson on Input. However, I find the ‘?’s pretty ugly. Especially when you have several. So here’s the syntax for pretty-fying them.
Disp "Area is:",L*W
Here’s the output:
One more thing: the ‘Input’ function only accepts numbers. This can be lame if you want the person to, say, type in their name. (What’s your name? 1337)
The TI-86 has a different function called “InpSt” (Input String), which lets the user input a string of letters, not numbers. However, I’m pretty sure that the TI-83/84/80 families do not have this. Darn.
That’s all you need to know about Input to succeed in life
Now let’s talk about math. (Don’t worry, it’s a bit more interesting than normal math.) We’ve already touched on it, and the best way of explaining it is giving a sample program.
(Note: I’m going to use ‘->’ for the Store key throughout this entire guide. The Store key has Sto> written on it (the > is filled in though) and is used for assigning values to variables.)(I’ll also use sqrt() for the square root sign)
This program will solve for the hypotenuse of a right triangle.
Input "A:",A Input "B:",B A^2 + B^2->D Disp "C squared is:",D sqrt(D)->C Disp "Hypotenuse is:",C
So the moral of the story (erm, program, I mean) is that you can do math with variables in programs.