title: Using switch statements inside a for loop
body: <p>I have a question about weather it's legal to use a switch statement inside a for loop. The way its written below Eclipse gives me an error and won't let me use switch(n) on the second statement in the for loop. What I want to do is write...<br/></p>
  
  <p>This old man, he played 1 <br/>
  He played knick-knack on my thumb. <br/></p>
  
  <p>Is there a better way of solving the problem below with a for loop and switch statement? I want to write out the paragraphs 10 different with the different number and different case. So 1 thumb, 2 shoe, 3 knee.... until 10. </p>
  
  <pre><code>import acm.program.*;
  
  public class SingSong extends ConsoleProgram {
  
      public void run() {
          for (int n = 1; n &lt;= 10; n++) {
              println("This old man, he played " + n);
              println("He played knick-knack on my" + switch(n));
              println("With a knick-knack, paddy-whack,");
              println("Give your dog a bone");
              println("This old man came rolling home");
  
              switch (n) {            
                  case 1 : println("thumb"); break;
                  case 2 : println("shoe"); break;
                  case 3 : println("knee"); break;
                  case 4 : println("door"); break;
                  case 5 : println("hive"); break;
                  case 6 : println("sticks"); break;
                  case 7 : println("heaven"); break;
                  case 8 : println ("pate"); break;
                  case 9 : println("spine"); break;
                  case 10 : println("shin"); break; 
              }
          } 
      }
  }
  </code></pre>