title: write a code to find the number of words in a string using methods
body: <p>I've been looking and I can't find anywhere how to write a word count using 3 methods. Here is what the code looks like so far. I'm lost on how to use the methods. I can do this without using different methods and just using one. Please help!!!</p>
  
  <pre><code>    public static void main(String[] args) {
      Scanner in = new Scanner (System.in);
      System.out.print("Enter a string: ");
      String s = in.nextLine();
      if (s.length() &gt; 0)
      {
          getInputString(s);
      }
      else 
      {
          System.out.println("ERROR - string must not be empty.");
          System.out.print("Enter a string: ");
          s = in.nextLine();
      }
      // Fill in the body with your code
  }
  
  // Given a Scanner, prompt the user for a String.  If the user enters an empty
  // String, report an error message and ask for a non-empty String.  Return the
  // String to the calling program.
  private static String getInputString(String s) {
      int count = getWordCount();
      while (int i = 0; i &lt; s.length(); i++)
      {
          if (s.charAt(i) == " ")
          {
              count ++;
          }
      }
      getWordCount(count);
      // Fill in the body
  
      // NOTE: Do not declare a Scanner in the body of this method.
  }
  
  
  // Given a String return the number of words in the String.  A word is a sequence of 
  // characters with no spaces.  Write this method so that the function call:
  //      int count = getWordCount("The quick brown fox jumped");
  // results in count having a value of 5.  You will call this method from the main method.
  // For this assignment you may assume that
  // words will be separated by exactly one space.
  private static int getWordCount(String input) {
      // Fill in the body
  }
  
  }
  </code></pre>
  
  <p>EDIT:
  I have changed the code to</p>
  
  <pre><code>private static String getInputString(String s) {
      String words = getWordCount(s);
      return words.length();
  }
  
  
  private static int getWordCount(String s) {
      return s.split(" ");
  }
  </code></pre>
  
  <p>But I can't get the string convert to integer.</p>