CS 111 - Fall 2012
Exam 1 Solutions
Note that for the write code questions, the web page removes the indentation originally given to the code.
- B
- D
- C
- E
- E
- E
- C
- D
- B
- A
- B
- D
- A
- D
- C
- B
- E
- B
- D
- E
- Picture p;
p = new Picture(640, 480);
Turtle t;
t = new Turtle (p);
int count;
t.setPenColor (Color.BLUE);
count = 0;
while ( count < 4)
{
t.forward (50);
t.turn (90);
count = count + 1;
}
t.penUp();
t.forward (100);
t.penDown();
t.setPenColor (Color.RED);
count = 0;
while ( count < 4)
{
t.forward (50);
t.turn (90);
count = count + 1;
}
p.show();
-
// Start a new method
public static void drawDodecagon (Turtle tParam, int len, Color c)
{
Color temp = tParam.getPenColor();
tParam.setPenColor (c);
int count;
int sides;
sides = 12;
count = 0;
while ( count < sides)
{
tParam.forward (len);
tParam.turn (360/sides);
count ++;
}
tParam.setPenColor (temp);
} // end of the new method
This topic: CS111
> WebHome >
CS111Fall2012 > Exam1SolnF12
Topic revision: r1 - 2012-10-23 - 16:25:39 - Main.troy