I created a very simple program that will compute the ...



I created a very simple program that will compute the hypotenuse of a right triangle, given the two sides, using the Pythagorean Theorem, A2 + B2 = C2.

To begin, hit the PRGM button, and then select the NEW option. Now you must name your program. As you will see, there are letters in green placed above many of the keys. For example, if you wanted to spell “COOL”, you would type these buttons: PRGM, 7, 7, ). I named my program PYTHAG.

Once you have named your program, you are ready to begin writing the code. In order to be able to input the lengths of the sides of the triangle (or any value in general) from the calculator you need to do the following:

• Press the PRGM button

• Select the I/O option

• Select the 2:Prompt option

This places Prompt on the first line of your program. What this function will do is prompt the user of the calculator, (you), for any single variables that you choose, ie X, Y, A, B, etc. In this case, we want to prompt for ‘A’ and ‘B’, the most popular representation of the two shorter sides of a right triangle. So we write A,B following the Prompt, and we have Prompt A,B. Now hit enter to get a new line.

Next, we want to calculate the value of the hypothesis. We know that A2 + B2 = C2, so then, C = A2 + B2. On the next line of your program, select the button and then type: A2 + B2) , and then select the STO( button and then C. So the line of code, should look like this: A2 + B2)(C. This stores the value of A2 + B2 to C. Hit enter to get to the next line.

Next we want to display the value of the Hypotenuse. To display information, select the PRGM button, and then the I/O option, and then the 3:Disp option. This places Disp in the line where your cursor is. To display characters (ie: strings of symbols that aren’t variables) insert a ‘ “ ’ and then type what you wish and then close the sentence with another ‘ ” ’. (Make sure what you type doesn’t exceed the width of the screen or it will get cut off.) I wrote “HYPOTENUSE IS”, so my line of code looks like this:

Disp “HYPOTENUSE IS”. (Hit enter) And now we want to display the value of the hypotenuse which we called C. To display the value a variable, no parentheses are necessary, so just type Disp C. And your program is complete.

Running the program is very simple. Hit the PRGM button and select the program by using the arrows. Hit enter and this displays a line on your screen that reads “prgm(NAME)”, where NAME is the name of the program. Hit enter again. As you see, you are prompted for the value of A. Enter a value and hit enter and do the same for B. Vioala! There is the answer.

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download