As6.doc

advertisement
Assignment 6: Algorithms
Read Snyder Chapter 10
Do: Lab 2.2
due: start of next class
10 Points Total
Keyboard Shortcut Exercise
0) Open this file in Internet Explorer or Word. Put your cursor at X. Determine the
sequence for changing this paragraph to all lower case using only Home, Shift, End,
Arrows, and the Format menu (using Alt-O to access it), and write that sequence here:
Lab 2.2 Exercises
1) Prepare a cup of tea using a tea bag. You may describe adding cream, sugar, lemon,
honey, etc., but mention these ingredients in your write-up.
START STATE:
END RESULT:
ASSUMPTIONS:
PROCEDURE:
1)
2)
3)
4)
2) Suppose you are told that your favorite movie is on television right now, but you are
not sure which channel it is on. Without the use of a program guide (that is, without
using things like TV Guide or the newspaper program listings), find the channel
broadcasting the movie. Assume, of course, that you could recognize any part of the
movie if you saw it.
START STATE:
END RESULT:
ASSUMPTIONS:
PROCEDURE:
Turtle Graphics Exercises
3) Imagine you have a robotic turtle that you can drive around. It always has a pen
dragging behind it. You can tell it one of 4 instructions:
forward(
)
backward(
left(
)
right(
A)
)
)
move turtle the specified number of millimeters (10 mm = ___ ) in the
direction it’s currently facing. Ex: forward(20) move 2 cm forward.
moves the turtle the specified number of mm in the direction opposite the
current heading. For example, backward(20) moves 2 cm backward.
turns the turtle the specified number of degrees to the left, relative to the
current heading. For example, left(90) makes a 90 degree left turn.
turns the turtle the specified number of degrees to the right, relative to the
current heading. For example, right(90) makes a 90 degree right turn.
B)
C)
Angle Key:
Write instructions to draw the pictures above. Approximate lengths are fine. Assume
when you start the turtle is on the point marked X and is facing toward the top of this
page.
A)
B)
C)
4. Identify at least one example of iteration in the algorithms you wrote for this lab.
Explain which steps are being repeated and what determines when the repetition
stops.
5. Identify at least one example of a conditional in the algorithms you wrote for this
lab.
Download