title: Vigenere cipher while maintaining space and encrypt only words starting with consonent letters [Java]
body: <p>I'm trying to write a program which will encrypt a sentence using Vigenere cipher, but only the words starting with consonant letters, and while storing spaces.
  I'm not very good with Java yet, but I wrote a method which encrypts any given word (all small letters) I had thought using array to print spaces where needed and ignore words starting with vowels would be enough, but doing so is actually giving me wrong output whenver I'm printing the 2nd word or so on of the array. Could someone please guide me what I'm doing wrong? And is there any better way to do this?
  Here's my code so far:</p>
  <pre><code>public class Main {
  public static void main(String[] args) {
  
      Scanner u = new Scanner(System.in);
      final String k = u.next();
      u.nextLine();
      String message = u.nextLine();
      String[] f = message.split(&quot; &quot;);
      System.out.println(encipher(message,k));
  
      for (String s : f) {
          if (s.charAt(0) == 'a' || s.charAt(0) == 'e' || s.charAt(0) == 'i' ||
                  s.charAt(0) == 'o' || s.charAt(0) == 'u') {
              System.out.println(s);
          } else {
              System.out.println(encipher(s, k));
          }
  
      }
  }
  
  
  public static String encipher(String message, final String key)
  {
      String output = &quot;&quot;;
  
      for (int x = 0, y = 0; x &lt; message.length(); x++)
      {
          char c = message.charAt(x);
          if (c &lt; 'a' || c &gt; 'z')
              continue;
          output += (char) ((c + key.charAt(y) - 2 * 'a') % 26 + 'a');
          y = ++y % key.length();
      }
  
      return output;
  }}
  </code></pre>
  <p>You can see the difference between the normal output (ignores spaces and vowel/consonant) and the array output. For a string key obi and string message &quot;olimpiada brasileira de informatica&quot; it should print &quot;olimpiada psigjtsjzo em informatica&quot; but in array its printing &quot;olimpiada psigjtsjzo rf informatica&quot; [ignore the printline thing for now on, I'll fix it once I get the encryption right]</p>