| Ti Tutorial # 2 | ||||
| Tutorial #2 Introduction This is the second tutorial. In this tutorial we will learn how to store numbers into variables and use If-then-Else statements. New commands to know The sto-> key- used to store into a variable. If-Evaluates if a statement is true. If it is true evaluates the next command. If false skips the next command. Found in the prgm menu. Then-Sometimes used with the if command. Found in the prgm menu. Else-If the if statement is false, does the operation after the else command. Found in prgm menu. Str 1-10-You can store words into strings. Found in vars,7,1-0. Input- gets an answer from the user. Found in the prgm menu. Programs to make We will be making programs that evaluates if a command is true. The code ClrHome Input a Input b If a>b Disp �number 1�,�was bigger� If a<b Disp �number 2�,�Was bigger� If a=b Disp �the two numbers�,�are equal� Explanation Input a and Input b both tell the user to input a number then press enter. A and B are both what the user puts in. The if statements evaluate whether a was greater than b, a was less than b, or a was equal to b, and gives the corresponding disp command. ClrHome Disp �what is�,�your favorite�,�thing to� Input �do?�,str1 If str1= �programming� or str1=�program� Then Disp �cool dude� Else Disp �what is your�,�problem� Explanation Did you know that you could display things using the input command? If you do use quotes you must use a comma and then the variable you store it into. Strings only store words and variables only store numbers. Try it vice virsa and nothing will work. The else command executes only if the if-then statement is false. Conclusion We have learned how to test if something is true and what to do if it is true. Also we have learned how to store into variables and strings. Make it Make a program that says you are evil if you are Kyle Eshmo or Jason. If it says any thing else you are not evil. tip of the day If you can�t find sin( cos( or tan( in trig, switch to degree mode. |
||||