TWiki> CS111 Web>CS111Fall2014>Exam1SolnF14 (2014-10-21, Main.troy)

# CS 111 - Fall 2014

### Exam 1 Soltions

1. D
2. A
3. C
4. D
5. B
6. E
7. C
8. A
9. C
10. A
11. B
12. E - (Answer C was also scored as correct - however, correct answer is 3.4)
13. B
14. B
15. D
16. B
17. D
18. C
19. D
20. B
NOTE: The answers for Q 21 and 22 lose indentation due to the way the wiki removed extra space characters.

public static void main (String[] args)
{
Turtle t1;
World w1;

w1 = new World( );
t1 = new Turtle (w1);

// draw a red square
t1.setPenColor (Color.RED);
t1.turn (90);
t1.forward (100);
t1.turn (90);
t1.forward (100);
t1.turn (90);
t1.forward (100);
t1.turn (90);
t1.forward (100);

// move up away from the red square
t1.penUp();
t1.forward (50);
t1.penDown();

// draw a blue square
t1.setPenColor (Color.BLUE);
t1.forward (100);
t1.turn (90);
t1.forward (100);
t1.turn (90);
t1.forward (100);
t1.turn (90);
t1.forward (100);

w1.show();
}

public static void drawDodecagon (Turtle t, int len, Color c)
{
Color originalColor = t.getPenColor();
t.setPenColor (c);

int i = 1;

while (i <= 12)
{
t.forward (len);
t.turn (360/12); // 360/12 => 30
i = i + 1;
}

t.setPenColor (originalColor);
}

-- Main.troy - 2014-10-21

Topic revision: r1 - 2014-10-21 - 14:14:21 - Main.troy

 Copyright 2016 The Board of Trustees of the University of Illinois.webmaster@cs.uic.edu WISESTHelping Women Faculty AdvanceFunded by NSF