CompSci 94 Spring 2019 Exam 1 Solutions Problem 1 Answer is C Problem 2 - If Tennessee is surrounded by <ol>, answer is A - If Tennessee is surrounded by <ul>, answer is B Problem 3 Answer is D Problem 4 Answer is B Problem 5 Answer is B Problem 6 A) - if number is #2E0A3C, answer is: (46, 10, 60) 2 * 16 + 14 = 32 + 14 = 46 0 * 16 + 10 = 10 3 * 16 + 12 = 48 + 12 = 60 - if number is #2B3A0C, answer is: (43, 58, 12) 2 * 16 + 11 = 32 + 11 = 43 3 * 16 + 10 = 48 + 10 = 58 0 * 16 + 12 = 0 + 12 = 12 B) - if number is (35, 12, 27), answer is: #230C1B 35 = 2 * 16 + 3 = 23 hex 12 = 0 * 16 + 12 = 0C hex 27 = 1 * 16 + 11 = 1B hex - if number is (38, 29, 11), answer is: #261D0B 38 = 2 * 16 + 6 = 26 hex 29 = 1 * 16 + 13 = 1D hex 11 = 0 * 16 + 11 = 0B hex Problem 7 Answer is A Problem 8 Answer is D Problem 9 Answer is C Problem 10 - if second line is panda move right 1.0, then answer is D - if second line is panda move left 1.0, then answer is B Problem 11 A) something B) cow procedure (quadruped procedure also ok) C) this.panda, "Good morning", 2.0 D) animal, item, someNumber E) Biped, textString, decimalNumber Problem 12 See pictures. Note there was different code on different exams. Check the code to match your test. - if first line is marchHare move Forward - there is one picture - if first line is marchHare move Backward - there is another picture Problem 13 A) - if someColor is Blue, answer is cat - if someColor is Yellow, answer is horse B) - if someColor is Green, answer is horse - if someColor is Red, answer is dog Problem 14 A) Different random numbers are generated for the move up and move down instructions. B) constant DecimalNumber amount <- nextRandomRealNumberInRange 1.0, 4.0 this.move up amount this move down amount Problem 15 DoTogether this.pig turnToFace this.bunny this.bunny turnToFace this.pig this.pig move forward this.pig getDistanceInFrontOf this.bunny / 2.0 this.bunny move forward this.bunny getDistanceInFrontOf this.pig - 0.5 this.panda turnToFace this.pig this.panda say "hello" this.pig turn right 0.5 the.panda move up this.pig getHeight this.panda move forward this.panda getDistanceTo this.bunny + this.bunny.getDepth this.panda move down this.pig getHeight doTogether this.bunny setOpacity 0.0 this.pig setOpacity 0.0 this.panda turnToFace this.camera this.panda setPaint red Problem 16 [ note: Chicken procedure so "this" is chicken] if both this.getdistanceTo creature1 < this.getdistanceTo creature2 and this.getdistanceTo creature1 < this.getdistanceTo creature3 creature1 say "I'm closest" else // we know creature1 is not the closest if this.getdistanceTo creature2 < this.getdistanceTo creature3 creature2 say "I'm closest" else creature3 say "I'm closest"