title: Java String Shortener
body: <p>The instructions for the assignment are:
  In many methods of communication throughout the last century, from telegrams to SMS messages to tweets, there is a benefit to reducing message length: either the number of characters is limited or using more characters incurs extra cost. Your job in this assignment is to write a program which takes a message as a string and reduces the number of characters it uses in a set way.</p>
  
  <p>The first thing your program will do is ask the user to type a message which will be stored as a String. If the message contains less than 10 characters the program should print “This doesn’t need shortening!” and finish.</p>
  
  <p>Otherwise, the message should be immediately converted to lowercase as this will make processing much easier. The program should then create a string in which every vowel (a, e, i, o, and u) from the message is removed unless the vowel is at the very start of a word (i.e., it is preceded by a space or is the first letter of the message). The program should also remove every repeated non-vowel character (i.e., if a character appears several times in a row it should only appear once at that location).</p>
  
  <p>Finally, the program should output the shortened message, the number of vowels removed, the number of repeated non-vowel characters removed, and how much shorter the shortened message is than the original message. The exact format in which the program should print this information is shown in the sample runs.
  my code is:</p>
  
  <pre><code> import java.util.Scanner;
      import java.lang.Math;
  
      class Main {
           public static void main(String[] args)
            {
  
           Scanner scan = new Scanner(System.in);
           System.out.println("Type the message to be shortened");
           String message = scan.nextLine();
           int messagelength = message.length();
           String shortmsg = "";
           int vowel = 0;
           if (messagelength &lt; 10)
           {
             System.out.print("\nThis doesn't need shortening!");
           }
           else
           {
             message = message.toLowerCase();
             for(int i = 0; i &lt; message.length(); i++)
             {
              if (i == 0)
              {
                 shortmsg = "" + message.substring(0,1);
               }
               else
               {
                 if(message.charAt(i - 1) != ' '){
                 if (
  
                     message.charAt(i) != 'a' &amp;&amp;
                     message.charAt(i) != 'e' &amp;&amp;
                     message.charAt(i) != 'o' &amp;&amp;
                     message.charAt(i) != 'u' &amp;&amp;
                       message.charAt(i) != 'i')
  
                 {
                   shortmsg += message.charAt(i);         
                 }
                 else
                 {
                   vowel++;
                 }
                 }}
             }
  
             System.out.println("Shortened message: " + shortmsg);
             System.out.println("Vowels removed: " + vowel);
             System.out.println("Total characters saved: " + vowel);
           }}}
  </code></pre>
  
  <p>when I put in "Please shorten this message" the output is "Shortened message: pls hrtn hs ssg"
  I have been working on this assignment for days and I am failing the class because of it can someone please guide me to the correct answer.</p>
  
  <p>Thanks for your help.</p>