Skip to content

Latest commit

 

History

History
executable file
·
28 lines (21 loc) · 789 Bytes

67dd.md

File metadata and controls

executable file
·
28 lines (21 loc) · 789 Bytes

Back to questions

67dd: Word count

Write a Java program that reads from standard input, printing the number of lines, words and alpha-numeric characters that have been encountered when the end of input is reached. A word is defined to be a continuous sequence of alpha-numeric characters, so that Dog, 1955 and a2ps are each words, while type-based is two words.

For example, given the following input:

People love me at parties
when they ask me "Oh, you are a computer guy?
Can you fix my laptop?"
And I respond...
"Computer Science is no more about computers
than astronomy is about telescopes"

your program should print:

Lines: 6
Words: 35
Characters: 149

Reading from standard input can be performed as in question 2d33.