CS 101 - Introduction to Computing

Fall 2009

Exam 1 Solutions

The answer to the multiple choice questions are:
  1. c
  2. c
  3. b
  4. b
  5. b
  6. a
  7. a
  8. d
  9. c
  10. d
  11. c
  12. a
  13. b
  14. b
  15. c
  16. e
  17. c
  18. a
  19. a
  20. c

  21. World w = new World ();
    Turtle t = new Turtle (w);
    int length;
    
    length = SimpleInput.getIntNumber("Enter length of each side of the squares",
                                      1, 500);
    
    t.setPenColor(Color.red);
    t.turn (90);
    t.forward (length);
    t.turn (90);
    t.forward (length);
    t.turn (90);
    t.forward (length);
    t.turn (90);
    t.forward (length);
    
    t.penUp();
    t.forward(length/2);
    t.penDown();
    
    t.setPenColor(Color.blue);
    t.forward (length);
    t.turn (90);
    t.forward (length);
    t.turn (90);
    t.forward (length);
    t.turn (90);
    t.forward (length);
    
    w.show();
    

  22. public static void drawOctadecagon (Turtle t, int len)
    {
     for (int count = 0 ; count < 18 ; count++)
       {
        t.forward (len);
        t.turn (20);   // this is 360/18
       }
    }