We first need to convert the dates in the table below into day-of-year numbers. This function returns the number of days between day 1 and day 2. The date intervals shown for each sign of the zodiac correspond to those found in many horoscopes:.
In our program we need to convert a user-entered month and day into the format MM. DDYY that the dbd function requires. To the right is a test program that only displays the daycode and the daynum values. This test assures us that these expressions are working properly.
Complete the missing parts of the program. Then … EndIf. This provides another opportunity to take advantage of Copy and Paste. However, be careful with Capricorn. Test your program thoroughly referring to the Zodiac chart above. At the end of all the If statements, simply display zodsign.
If the dbd function receives invalid information such as month 13 or day 45 then an error occurs and the program terminates.
In order to be sure valid information is entered, we will need to build a loop to repeatedly ask for the data until good numbers are entered. In this lesson, you will learn about the loop concept in programming and examine the For…EndFor loop.
The TI-Basic programming language has the ability to process a set of statements over and over. This repetition of statements is called looping. See For , While , and Loop to the right. The While. For more information about additional Control structures in this menu, see the Reference Guide at the TI Codes website. The For…EndFor loop is used to process an arithmetic sequence of values. Selecting the For…EndFor statement from the control menu gives you the necessary components for building the rest of the structure:.
The commas after the word For indicate that you need to provide at least three components. An additional comma and a fourth component can be added for the increment value. Note: If the increment value is 1, the fourth component can be omitted.
Running the program produces the results shown to the right in a split screen to see the code and the result. After the loop ends, i will be larger than the end value. Add another Disp i statement after the EndFor statement to see for yourself.
You can use DispAt 1, i, i2 to place all output information on the same line of the screen. Try it. The output is displayed too fast to observe each pair of values. There are two ways to fix this problem. Since Wait is the last option, use the up arrow. Adding Wait 3 after DispAt tells the program to wait or pause for three seconds after each new set of values is displayed. Adding getKey 1 you have to type the number 1 after DispAt pauses the program until a key is pressed. This gives the user greater control than Wait.
In this lesson, you will learn about the most versatile of the loops, While…EndWhile loop. The structure looks like this:. Without this initialization, the variable k could be undefined or contain any stored value, introducing an unknown value into the program. The program demonstrates the While loop equivalent of the following For loop:. This illustrates the power and convenience of using a For loop which is more compact.
The output of the code segment is shown to the right with some non-positive numbers entered to see the effect. Try to write the statements for While…EndWhile structure without peeking at the next page!
Finally, complete the loop body by providing an error message. The Text statement pauses the program and displays the promptString in a dialog box. The final program valid to the right produced the interaction seen earlier in this lesson.
In this lesson, you will learn about the all-purpose Loop…EndLoop structure. The Loop…EndLoop structure creates a more flexible but possibly hard-to-follow loop. It repeatedly executes the statements in the loop body. Note that this loop will be executed endlessly, unless an Exit instruction is executed somewhere inside the loop body. Exit forces program flow to process the statement immediately after EndLoop. Example: How many random numbers from 1 to 6 can be generated before two consecutive values are the same?
When the random integer generator randInt 1,6 produces two consecutive identical values, then the loop Exits to process the Disp statement at the bottom of the program. The same effect can be accomplished with a While loop. Think about how you could do this. Sample output of such a program is shown to the right. The prompt portion of a Request statement must be a string so the player variable a number is converted to a string with the string function found in the Catalog.
Next build the Exit condition. When a player guesses the number, then the loop will Exit. Use the primitive If statement here:. Recall that If without Then processes the next statement when the condition is true; otherwise, the next statement is skipped. This unique statement switches the value of player between 0 and 1. That is, when player is 0 the statement changes it to 1 and when player is 1 the statement changes it to 0. Try it! The user sees a 1 or a 2 even though the computer uses 0 and 1 for the players.
This application, "Bank Notices," makes use of loops to enter as many values as needed and, as an extension, checks for valid values entered and uses If statements to display an appropriate message. The program first sets up a loop to continue until the entered value is zero. But when a is not negative then the square root calculation and an If statement is processed and then the Disp statement is executed. When 0 is entered the program ends. Loop is used when you are certain that you want the loop body to run at least once and it must contain an Exit statement, usually as part of an If statement.
A bank customer can have several bank accounts at a certain bank. The user will enter account balances. The program will determine the average balance amounts, and display the number of accounts, the average of the balances, and an appropriate message to the user.
In Method 2, we also have to count the number of account balances so that we can divide the total by that count. Your program should display 1 the number of account balances entered, 2 the average of the account balances, and 3 the appropriate message based on the balance average. The value of n is added to the variable t and then that sum is stored back into the variable t. At the end of a loop, t will contain the total of the n values encountered.
The While…EndWhile loop above continues counting and accumulating the amounts as long as is not entered. When is entered, the loop stops, and the results are displayed. As part of your input routine, check to make sure that the value entered is a legitimate amount greater than 0 , and take appropriate action when the entered value is not legitimate. In this lesson, you will learn about using Lists in programs to produce interesting, interactive data graphs.
TI-Basic does not provide direct graphical statements. A program can define functions for graphing and can create lists to produce scatterplots, but cannot plot points directly. The list elements values between the braces are addressed using square braces after the list name, such as in mylist[3] , which refers to the third element in mylist. Add elements to a list by storing a value in the position immediately after the last value of the list.
Knowing how many elements are in a list is very helpful. This command is often used to add an element to the end of a list. Create a new program we called it randots , and use the argument n. The two most common are rand and randInt. Add the Calculator app to the new window on the right.
Do you see why we chose those intervals for the random numbers functions? In this lesson, you will learn about controlling individual elements in lists and discover the method of running a program dynamically from a Notes app Math Box.
In the previous lesson, we wrote a program that generates two lists of random integers and displays those lists in the form of a scatterplot in a Graphs app. Recall the output of the randots n program. A sample is shown to the right. The randots program was limited to generating only integral values for the x- and y-coordinates of the scatterplot so all the points are located on the grid points of the graph.
In this activity, we'll extend the program to include non-integer values so that the plot will be more densely packed.
First, let's examine the rand and rand n function outputs in a Calculator app. Notice that without an argument, rand generates a single random decimal between 0 and 1. With an argument of 3, however, it gives a list of three decimals between 0 and 1. This random list can then be used as part of an expression to change those values to go beyond the range of 0 and 1. We need to use this knowledge to generate a random decimal between and These expressions generate n decimal values of xs between and 10 and n values of ys between -6 and 6.
You will see that all the dots disappear except for one. This is a result of the program responding to the new value for k 1 in our demo causing the program to respond from the Math Box in the Notes app. The program is running properly now that the argument k is defined. When you toss a pair of 6-sided dice, the sum of the values on the two dice can range from a low of 2 by rolling two ones to a high of 12 by rolling two sixes. But, are the eleven totals all equally likely, or do some totals occur more often than others?
Now that k is defined, the program runs from within the Notes app. Another way of generating the Gasket that we will use in this project is called the Chaos Game. The rules are:. We will use a growing scatter plot to visually represent this game. These variables are not yet defined so no graph will appear when you press enter. Also, there will be a message related to creating sliders for xs and ys, but at this point, click on cancel. We want the value of n the number of points plotted to increase and not decrease.
Do this by keeping track of the last previous value of n and compare it to the new current value of n. If the new value is less than the last value, it will be ignored by setting n to be the last value. The next portion of code checks to see if n is less than the previous n when the left arrow of the n slider is clicked. Recall that the rand function generates a random decimal from 0 to 1. The x- and y-coordinates will both have a value between 0 and 1. Build a set of If statements based on v to compute the next midpoint.
At this location in the program, the last values of xs and ys are xs[n-1] and ys[n-1] ; we got here by increasing n but have not yet added the coordinates of another point to the lists. This analysis gives rise to the code seen to the right. See if you can implement this section of the program using that structure instead. Now back to the Local statement. Which variables in this program can be Local? Which variables are needed to produce the picture?
Note: Draw statements do not use parentheses. Using parentheses causes an error. You now see a screen like the one on the right. Press any key to close the drawing screen and return to the Calculator app. Before advancing, see if you can draw a line that is a diagonal of the screen. DrawCircle x , y , r where x , y is the center and r is the radius.
Color is determined by three values: the amount of R ed, G reen and B lue to mix together. Each of these three values must be in the range If you want a circle and its interior to be two different colors use two different pairs of statements:.
But if you draw the circle first, then the filled circle, you will not see the black circle because the red covers it. In this lesson, you will change the viewing window and investigate its impact on the Draw commands.
You will also learn about SetPen and DrawArc. The default drawing screen is odd compared to graphing: 0,0 is in the upper left corner and the y-values the vertical coordinates increase as you go down the screen.
Most graphical programming environments are like this. The SetWindow statement allows us to work with more familiar screen coordinates, but it does have an impact on the use of the drawing shapes. Run the program again. Do you see the rectangle near the center of the screen? The origin 0,0 is now at the center of the screen and the x- and y- coordinate system is just like a Graphs app standard window.
The width of the rectangle is measured to the right. Its height is measured upward. The unit length is similar to the Graphs unit. And the original diagonal line remains on the screen. The SetWindow statements did not affect the diagonal that was drawn first.
Change the shape of the arc by changing the width, height, start angle and arc angle. If you see any error messages just edit your numbers accordingly.
In the previous example you used equal width and height values to make an arc of a circle. But the width and height of the arc can be different. This allows for elliptical arcs, too. This helps to preserve the code without processing it in case you need it later. In this lesson, you will write a program to plot a point, automatically move it, and display its coordinates as it moves.
Use [esc] to end the program. So far you have experienced drawing shapes line, rectangle, circle and arc. It is required. We use the variables x and y because they will change value in the program to make the point move.
Try some of the other styles 1 to 13 for the third parameter. The loop will make the point appear to move by changing the x-coordinate. But first, the point needs to be erased from its current position. Press [esc] to end the program and modify the program to keep the point with in the screen bounds:. Syntax : DrawText thing1, thing2, thing3, …. Write a program to move an object on the screen using the arrow keys an interactive animation. This forms the basis of many video games.
In the previous lesson you made a point move across the screen by itself and used getKey 0 to end the program. Now you will write a program that lets the user move the point or any shape using the arrow keys. In this project you will use getKey 1 which pauses processing and waits for a keypress. Use the arrow keys. Press [esc] to end the program. If all goes well the point moves… and leaves a trail behind. What happens when the point gets to the edge of the screen?
Currently, it goes off the screen. There are some choices to make here: you can make it simply stop at the edge and not go any further or you can make it go elsewhere, typically to the opposite edge of the screen. This last option is called wrap-around or toral mode. This project only deals with manually moving a point. Consider replacing the point with some shapes. Within the same problem, write a new program called drawshape x, y and, in the movepoint2 program, use the statement drawshape x, y instead of PlotXY x,y,1.
See an example to the right. In the drawshape x, y program, draw some shapes using x and y as a reference point.
Your object can then consist of several different pieces and use several colors. Clear all by itself clears the screen. To erase or clear just a rectangular portion of the screen use: Clear x, y, width, height similar to DrawRect. Ready for more? Now that you have completed the course, you are ready to try your hand at some more challenges! Make sure you have completed all the Units prior to starting this section.
The projects here will have you apply what you have already learned. Download the document here for challenges to choose from. If you get stuck, refer back to the previous Units in the course. For an extra challenge, design your own program from scratch. We would love to see your creativity! Good Luck and Get Coding! All rights reserved. Download free day trial versions of the most popular TI software and handheld emulators.
Learn about the math and science behind what students are into, from art to fashion and more. We are here to help with distance learning resources for schools and districts. See our latest posts. Unit 1: Program Basics.
Step 1 Last Skill Builder 2. Step 1. First Introduction. Step 2 Last Skill Builder 2. Step 2. In the Name field, type the name of your first program, hello.
We'll discuss Type in a later lesson. Click OK , or press enter. First Step 1. Step 3 Last Skill Builder 2. Step 3. First Step 2. Step 4 Last Skill Builder 2. Step 4. All programming commands are found in the menu.
The keyword Disp is pasted into your program. First Step 3. Step 5 Last Skill Builder 2. Step 5. Inside the quotes, type the text Hello, World! Use the shift key for capital letters, and press the key to select the exclamation point. Note: You must type the quotes before typing the text. First Step 4. Step 6 Last Skill Builder 2. Step 6. First Step 5. Running Programs and Evaluating Functions. Getting Values into a Program.
Displaying Information. Using Local Variables. Differences Between Functions and Programs. Calling One Program from Another. Controlling the Flow of a Function or Program. Using Loops to Repeat a Group of Commands. Changing Mode Settings. Debugging Programs and Handling Errors. To find out more or to change your preferences, see our cookie policy page.
Click Agree and Proceed to accept cookies and enter the site. You can control your preferences for how we use cookies to collect and use information while you're on TI websites by adjusting the status of these categories. Download free day trial versions of the most popular TI software and handheld emulators. Learn about the math and science behind what students are into, from art to fashion and more. We are here to help with distance learning resources for schools and districts.
See our latest posts. Overview Specifications. Making connections Computer software that allows for connectivity between your computer and TI Plus family graphing calculator. Key benefits: Save time by sending files to multiple connected graphing calculators at once Quickly take and manage screen captures Create and edit TI-Basic programs. Guidebook Download now. Screen Capture Take and manage screen captures from your connected graphing calculator quickly and simply.
Program editor Create and edit calculator TI-Basic programs using the program editor workspace.
0コメント