Solutions to CompSci 94 Exam 1 Fall 2019 1. HTML tags and file a)
e) samples.html 2) B 3) C 4) D 5) A 6. (193, 63, 77) is #C13F4D (44, 179, 29) #2CB31D 7) A 8) C 9) D 10) B 11) a. 3 b. 12 12) a) simple b) panda or biped c) "look out", DOWN d) stuff, someWay e) pig's width would be any number bigger than 2.5 f) pig's width would be less than or equal to 2.5 13) SEE PICTURE 14) A) four B) one 15) A) In the second move instruction a different random number is generated and used, resulting in the pig moving a different distance. B) procedure moveRandomly doInOrder constant DecimalNumber value <- nextRandomRealNumberInRange 2.0, 5.0 this move forward value this say "hello" this move backward value 16) do in order this.bunny turn left 1.0 asSeenBy this.tortoise this.tortoise move forward this.tortoise getDistanceInFrontOf this.hare this.tortoise move up this.hare getHeight this.tortoise move forward this.hare getDepth + this.tortoise getDepth this.tortoise move down this.hare getHeight this.tortoise setOpacity 0.0 this.bunny say "Watch this! do together this.bunny setPaint GREEN this.bunny turn right 2.0 17. Procedure changeMyColor with parameters DecimalNumber value, Paint default if value < 0.5 then this setPaint BLUE else if value < 1.0 then this setPaint RED else this setPaint default ALTERNATE SOLUTION: if value < 0.5 then this setPaint BLUE else if both 0.5 <= value AND value < 1.0 then this setPaint RED else this setPaint default ALTERNATE SOLUTION: if value < 0.5 then this setPaint BLUE else if both 0.5 <= value AND value < 1.0 then this setPaint RED else if value >= 1.0 this setPaint default else do nothing