Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- int characters = 0;
- int words = 0;
- int lines = 0;
- System.out.println("Type word or phrase to be analyzed: ");
- Scanner input = new Scanner(System.in);
- while (input.next() != null) {
- String s = input.nextLine();
- lines++;
- characters += s.length();
- String[] split = s.split(" ");
- for (String word : split) {
- words++;
- }
- }
- System.out.println("Characters: " + characters);
- System.out.println("Words: " + words);
- System.out.println("Lines: " + lines);
- input.close();
- }
Add Comment
Please, Sign In to add comment