title: "Simon says" in java
body: <p>"Simon Says" is a memory game where "Simon" outputs a sequence of 10 characters (R, G, B, Y) and the user must repeat the sequence. </p>
  
  <p>Create a for loop that compares the two strings starting from index 0. </p>
  
  <p>For each match, add one point to userScore. Upon a mismatch, exit the loop using a break statement. </p>
  
  <p>Ex: The following patterns yield a userScore of 4:
  simonPattern: R, R, G, B, R, Y, Y, B, G, Y
  userPattern:  R, R, G, B, B, R, Y, B, G, Y</p>
  
  <pre><code>import java.util.Scanner;
  
  public class SimonSays {
  public static void main (String [] args) {
    String simonPattern = "";
    String userPattern = "";
    int userScore = 0;
    int i = 0;
  
    userScore = 0;
    simonPattern = "RRGBRYYBGY";
    userPattern  = "RRGBBRYBGY";
  
    /* Your solution goes here  */
    char s;
    char u;
  
  
    for (i=0;i&lt;=10;i++) {
       s = simonPattern.charAt(i);
       u = userPattern.charAt(i);
  
       if (s == u) {
          userScore = userScore + 1;
          continue;
       }
  
    }
  
    System.out.println("userScore: " + userScore);
  
    return;
   }
  }
  </code></pre>
  
  <p>And the system said:</p>
  
  <pre><code>Runtime error (commonly due to an invalid array/vector access, divide by 0, etc.).
  </code></pre>
  
  <p>Why my code didn't work?</p>