Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class CuentaPalabras
- {
- public static void main( String [] args)
- {
- Scanner input = new Scanner( System.in ).useLocale( Locale.US );
- int countWord = 0;
- int countLine = 0;
- while( input.hasNextLine() ) {
- String line = input.nextLine();
- Scanner word = new Scanner ( line );
- while( word.hasNext() ){
- word.next();
- countWord ++;
- }
- countLine ++;
- }
- System.out.printf("%d words %n %d lines", countWord, countLine );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement