fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. Scanner inFile = new Scanner(System.in);
  13. int threeLetters=0;
  14. int wordCount=0;
  15.  
  16.  
  17. while(inFile.hasNextLine()){
  18. String line = inFile.nextLine();
  19. for (String word : line.split(" ")) {
  20. wordCount++;
  21. int wordLength = word.length();
  22. if (wordLength == 3){
  23. threeLetters++;
  24. }
  25. }
  26. }
  27. double percentage = 100*((double)threeLetters)/wordCount;
  28. System.out.println(percentage);
  29.  
  30.  
  31. }
  32. }
Success #stdin #stdout 0.13s 29572KB
stdin
Good morning life and all
Things glad and beautiful
My pockets nothing hold
But he that owns the gold
The sun is my great friend
His spending has no end
Hail to the morning sky
Which bright clouds measure high
Hail to you birds whose throats
Would number leaves by notes
Hail to you shady bowers
And you green fields of flowers
Hail to you women fair
That make a show so rare
In cloth as white as milk
Be it calico or silk
Good morning life and all
Things glad and beautiful
stdout
21.50537634408602