Email a file called asg2.lgo with all the solutions in it. Use comments (with ;) to write your group members on the assignment and/or to explain your ideas.
Write a procedure, octagon :size :pos, which draws an octagon of a particular :size at a particular position :pos on the screen. Test your procedure with some examples like “octagon 50 [30 -80]”. Write a procedure called stopsign that makes a realistic looking picture of STOP-sign, white letters and white border with a red middle, drawn on a black background. Your stopsign procedure should invoke octagon as a helper.
Write a procedure, polygon :sides :size, which draws a polygon on the graphics screen with a particular number of :sides where each side is a particular :length. Test your procedure with some examples like “polygon 5 50 “ (Hint: To make an n-sided polygon, you need to turn 360/n each time). In Logo you would write (/ 360 :n).
Write a procedure, prettyring, which draws a ring of pentagons (5-sided polygons), with sides of length 20, in the center of the screen. The pentagons can touch end to end or overlap -- whatever you think looks best -- as long as they make a pretty looking ring. You should use the procedure polygon to help. You would use (polygon 5 20) inside of a repeat statement with some other commands for turning or moving in between each pentagon.
Hints: To test whether numbers are greater or smaller than another you can use the symbols > and <. To test equality, use =, and to test not equals, use the command not. For example:
(< :a :b) - true when a is less than b.
(> :a :b) - true when a is bigger than b.
(= :a :b) - true when a is equal to b.
not (= :a :b) - true when is not equal to b.
Write a procedure, mini :item1 :item2 :item3, which outputs the minimum of the three items. (Hint: it can be done with three if statements). Test your procedure by writing and running the short program below:
To testmini
print [please type in 3 numbers or names, separated by spaces]
make "x1 read make "x2 read make "x3 read
print se [The smallest is] mini :x1 :x2 :x3
End
Write a procedure, sort :item1 :item2 :item3, which outputs a list of the three items in sorted order from smallest to largest. (Hint: it can be done with 6 if statements). To output more than one value, you will need to group the values together in a list. This is done with the "se" or "sentence" procedure. For example op (se 7 8 5) will output [7 8 5]. Test your procedure by writing and running a test program (similar to testmini in problem 4), which reads in three items and prints them out in sorted order.
Write a procedure, average :num1 :num2 :num3, which outputs the average of three different numbers.
Write a procedure, process3, which reads in three different numbers and prints out the average of the three numbers and the minimum of the 3 numbers. If the numbers are NOT all different, then your program should print a warning message, and stop. You should use the procedures mini and average. You also need to write a procedure are_different? that outputs “true when the three numbers are different and “false otherwise.