Advertisement
AustinShyd

Untitled

Apr 22nd, 2019
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.35 KB | None | 0 0
  1. // wrapper class to split the input into an array and then check the number of words based on the array.length
  2.         System.out.println("Input a sentence to get a word count: ");
  3.         userInput = keyboard.nextLine();
  4.         String[] sentence = userInput.split(" ");
  5.         System.out.printf("There are %s words in that sentence.", sentence.length);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement