Professor Simonson - How Computers
Work - CSC 195
Assignment 2 - 15 points
Due midnight, Thursday, February 8
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.
Procedures without Output Values
- Write a procedure, octagon :size :pos, which will draw a
STOP-sign 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, polygon :sides :size, which will draw a
polygon with a particular number of :sides and of a particular
:size on the screen. 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).
- 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
Procedures with Output Values
- Write a procedure, mini :item1 :item2 :item3, which
outputs the minimum of the 3 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
- make "x1 read make "x2 read make "x3 read
- print se [The smallest is] mini :x1 :x2 :x3
- 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 3), which reads
in 3 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 3 different
numbers and prints out the average of the 3 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.