{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

29-midterm-solutions

# 29-midterm-solutions - CS 106A Solutions to Midterm Exam...

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

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(); }

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

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

{[ snackBarMessage ]}

### Page1 / 3

29-midterm-solutions - CS 106A Solutions to Midterm Exam...

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

View Full Document
Ask a homework question - tutors are online