/ Published in: Java
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import java.util.*; public class HowEasy { int totalChars = 0, numTokens = 0; while(st.hasMoreTokens()) { if (t.matches("[A-Za-z]+\\.?")) { totalChars += t.endsWith(".") ? t.length() - 1 : t.length(); numTokens++; } } int average = numTokens != 0 ? totalChars / numTokens : 0; return (average <= 3) ? 250 : (average == 4 || average == 5) ? 500 : 1000; } }