You are allowed a textbook, calculator and notes on this exam. You are also allowed to use a computer to run Logo, view Blackboard (including past homework assignments), your W: drive, the course web site (http://webhost.bridgew/edu/hburgiel/COMP203), the textbook (http://www.cs.berkeley.edu/~bh/v1-toc2.html) and the user manual (http://www.cs.berkeley.edu/~bh/usermanual).
You are not permitted to use other computer software such as a chat client, email, or Facebook.
If you get stuck on a problem, leave it blank and return to it later. You will receive partial credit for code with minor errors, but please check your work if you have time.
to flower repeat 5 [repeat 36 [forward 10 right 10]~ right 72] end
This is a command. It has no output, and it displays a picture of a flower on the screen.
to pentagon :size repeat 5 [forward :size right 72] end
to longp :mylist ifelse greaterp (count :mylist) 3 [output "false] [output "true] end
? counter 5 5 4 3 2 1 0 ? counter 3 3 2 1 0 ?
to counter :num while not (lessp :num 0) [print :num make "num :num-1] end
to story local "verb local "noun local "adjective local "otherverb getwords ifelse equalp (last :noun) "s [make "otherverb "are] [make "otherverb "is] print (sentence :noun :otherverb word :adjective ", ~ [but still can] word :verb "!) end to getwords print [Type in a noun.] make "noun readword print [Type in a verb.] make "verb readword print [Type in an adjective.] make "adjective readword endIf the procedure runs correctly it should behave as shown below.
? story Type in a noun, singular or plural. cat Type in a verb. hunt Type in an adjective. sly cat is sly, but still can hunt! ? story Type in a noun, singular or plural. trees Type in a verb. grow Type in an adjective. green trees are green, but still can grow! ?
to recursive.sum :n if lessp :n 0 [output 0] output :n + recursive.sum :n-1 end