29-midterm-solutions

29-midterm-solutions - CS 106A July 16, 2009 Solutions to...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 106A July 16, 2009 Solutions to Midterm Exam The mean on the exam was a 32 out of 50, with a standard deviation of 11.5. Following our traditional practice for CS 106A, we have set the mean to be the lowest B+. Problem 1 - DivideBy10Karel (15 points) Common Errors: * findNextRow() just goes up 1 row, instead of all the way to the top. * fillRowWithBeepers() always just laid out 10 beepers. Forgot about the < 10 case. * forgetting to move one at the end, or going back to the beginning. public void run() { move(); while (beepersPresent()) { pickUpSomeBeepers(); findNextRow(); fillRowWithBeepers(); backToStart(); } } private void findNextRow() { move(); turnLeft(); while (beepersPresent()) { move(); } turnRight(); } //part a) private void fillRowWithBeepers(){ while (beepersInBag()) { putBeeper(); move(); } } //part b) private void pickUpSomeBeepers() { for ( int i = 0; i < 10; i++) { if (beepersPresent()) { pickBeeper(); } } } private void backToStart() { turnAround(); moveToWall(); turnLeft(); moveToWall(); turnLeft(); move(); }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Problem 2 – Short answer (10 Points) 2a) Solutions: isBuster? true hoop? 2.0 poo? Error: cannot convert double to int without a cast
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/14/2010 for the course CS 106A taught by Professor Sahami,m during the Fall '08 term at Stanford.

Page1 / 3

29-midterm-solutions - CS 106A July 16, 2009 Solutions to...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online