Guest User

Untitled

a guest
Jan 19th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. public static void main(String[] args) {
  2.  
  3. int characters = 0;
  4. int words = 0;
  5. int lines = 0;
  6.  
  7. System.out.println("Type word or phrase to be analyzed: ");
  8. Scanner input = new Scanner(System.in);
  9.  
  10. while (input.next() != null) {
  11. String s = input.nextLine();
  12. lines++;
  13. characters += s.length();
  14. String[] split = s.split(" ");
  15. for (String word : split) {
  16. words++;
  17. }
  18. }
  19. System.out.println("Characters: " + characters);
  20. System.out.println("Words: " + words);
  21. System.out.println("Lines: " + lines);
  22. input.close();
  23. }
Add Comment
Please, Sign In to add comment