Area of a Triangle


Calculating the area of a triangle is only a two step process and does not necessarily need a program. It is good to begin learning about programming languages, however, by starting simple. The formula A=(1/2)*b*h can be easily computed, but just think about how you do the process, then convert those to programming commands.

First, find the values of the base (B) and the height (H). Second, evaluate those values in the formula and save the computation as area (A).

The first step to writing any program is to enter the program menu on your TI-83. The PRGM button is located on the third row, third column. The following is an image of a program menu. Your menu may be blank, but not for long!

Use the right arrow to highlight the "NEW" category. There is only one option under this menu--"Create New." The "EDIT" category is to change/ammend any existing programs. And the "EXEC" category is for when we want to run any of our programs.

Once "Create New" is highlighted, go ahead and press "ENTER " on the bottom right of your TI graphing calculator to begin typing our program.

 

Title your program however you like, I chose "TRIANGLE." Notice the blinking cursor has an "A," this means it is set to "A-LOCK." Use the green "ALPHA" button to activate any of the green letters on your calculator. If you plan on typing a longer message, go ahead and activate the "A-LOCK" feature by pressing the yellow "2nd" button followed by the green "ALPHA." When naming your program, the calculator realizes you will most likely use all letters and automatically activates the "A-LOCK" for you. To exit this, (say you want a number in your program name) simply press the green "ALPHA" key once more to exit the "A-LOCK" feature at any time. The calculator only recognizes a program name of eight characters or less. Press enter and you can begin to type programming code!

Just like our algorithm above, the first step is to find the base and height. We must command the calculator to get these values. Two possible commands can be used for retrieving values for variables--"PROMPT" and "INPUT." With the prompt command the user must know what B and H represent. The "INPUT" can be used to substitute more than just numbers for variables, but functions, lists, and complex numbers can be substituted as well. To access these commands, press the "PGRM" key. The following menu appears.

The "CTL" menu stands for "program control." These more complicated commands will be used later. Use the right arrow to highlight the "I/O" menu, which stands for "program input/output."

You can select the any option either by simply pressing the number beside the command, or by highlighting with the up/down arrows and pressing "ENTER." Go ahead and choose "2:Prompt." Now tell the calculator what you would values you would like the user to input. The obvious choices are B and H. Use a comma between each variable you would like the calculator to request (5th row, 2nd column). When the program runs, it will now ask the user to enter values for the base and height.

Now that the calculator has values stored for B and H, we must command it to evaluate the area of the triangle. How do you compute the area of a triangle when you know the base and height? By using the formula of course! Press "ENTER" to begin a new command line. The expression (1/2)*B*H can be typed in then stored as variable "A" for area. The "STO" button (1st column, 8th row) is used to store an expression as another variable and looks like a right arrow on the screen. Almost like the equals sign in the formula.

In the screen above, the second command line evaluates the area using B and H input by the user and stores it as A. We asked for input, used it to evaluate, now we must have an output that tells the user the calculated area. Return to the "I/O" menu as before and select the "display" option--"3:Disp". You can display typed messages by using the green quotation marks above the addition key. If you want to display the current value for a variable simply type the variable, no quotes needed. For combinations of both, use a comma between variables and messages. After the program outputs the value of the area, it is complete. No more command lines are needed. To exit this screen, press the yellow "2nd" button and "MODE" or "QUIT" (top row). This returns you to the homescreen and can be used at any point.

Let's test the program. It is wise to run a test of something you know the answer to in order to assure the program really works. We know from the formula a triangle of base 10 units and height 5 units will have an area of 25 units squared. Press "PRGM" and while the "EXEC" (or execute) category is highlighted, choose the "TRIANGLE" program. "prgmTRIANGLE" will appear on the homescreen; simply press enter to execute. It should then ask for the values of the base and height. Input the values and press enter. The area should then be displayed if all is done correctly.

To run the program again, press enter.

For the complete version of my program, CLICK HERE. You can alter messages and displays to your liking. For instance, the message "THE TRIANGLES AREA IS" can be omitted and just the value for "A" be displayed.

 

Using this same method, you can type programs to evaluate any formula. For more practice, try writing some programs such as area of a circle, trapezoid, volume and/or surface area of a cylinder.

 

RETURN to intro/program list