Writing Simple Programs for Graphing Calculators

Using calculator programs can be an effective way to solve problems that require using a repetitive algorithm. Constructing a good program implies that the user understands how the calculator works and the operations the calculator will be performing. So that the calculator removes some of the repetitive use error by the user and improves efficiency. Calculator programs on a Texas Instrument's calculator requires some logic and a good understanding of the calculator. The simplest way to program is to think about teaching the calculator the steps you use in calculating a solution.

As an example, here is a program I've written for converting temperatures between the three scales, Kelvin, Fahrenheit, and Celsius.

Explanation

Below is a diagnosis of what the program is doing and how it was written. In programming, it is helpful to think of the calculator reading the program from left to right, top to bottom. So that the author can change the flow of the code read by the calculator with certain commands like Lbl and Goto.

Explanation
Program Code
The calculator's defaults need to be set so that the program will display digits properly. It is a good idea to reset MODE values to their default after the program runs if you change their values to something other than the defaults. With the three lines of code at the right, the calculator home screen is cleared, the mode is set to normal and the decimal point is set to float. All of these commands can be found under the MODE key. ClrHome
Normal
Float
The user is presented with a menu of options. Each option refers to a label from A-C. Selecting the option moves the user in the program to the appropriate label. Menu("CONVERT FROM","FAHRENHEIT",A,"CELSIUS",B,"KELVIN",C)
The user is prompted for the Fahrenheit temperature (variable F), the calculator calculates the other temperatures and stores them to other independent variables (C and K). Following the calculations, the program skips to label D. Lbl A
Prompt F
(F-32)*(5/9)->C
C+273.15->K
Goto D
The user is prompted for the Celsius temperature (variable C), the calculator calculates the other temperatures and stores them to other independent variables (F and K). Following the calculations, the program skips to label D. Lbl B
Prompt C
C*(9/5)+32->F
C+273.15->K
Goto D
The user is prompted for the Kelvin temperature (variable K), the calculator calculates the other temperatures and stores them to other independent variables (C and F). Following the calculations, the program skips to label D. Prompt K
K-273.15->C
C*(9/5)+32->F
Lbl D
After selecting and defining a temperature for conversion, the calculator computes the other temperatures just as the user would on the home screen. The program then clears the home screen, and uses the Disp command to displays the text "Celsius", "Fahrenheit", and "Kelvin", with each corresponding temperature. Lbl D
ClrHome
Disp "CELSIUS"
Disp C
Disp "FAHRENHEIT"
Disp F
Disp "KELVIN"
Disp K
End

This program uses 5 special operation commands; Prompt, Lbl, Goto, Menu, and Disp.

Command
Explanation
Prompt
Asks the user to enter a value.
Lbl
Marks a point in the program code for direction. This acts as a sign post.
Goto
Directs the reading of the program code to a specific point (sign post) described by the Lbl command.
Menu
Creates an on-screen set of options for the user.
Disp
Writes text to the home screen. The text can be defined by the programmer with "brackets", or the text may be a variable.

HINTS





Tuesday, November 23, 1999, KJC