import java.io.*; import java.util.StringTokenizer; public class EnimSonu{ public static void main(String argumendid[]) throws IOException{ //kasutame käske, kus voib tekkida vigu BufferedReader sisse=new BufferedReader( new FileReader("inimesed.txt") ); int aa=0; //sonad lauses int lause=0; //mitu lauset int meeles=0; //millises lauses rohkem String pikim=""; //lause String vordle=""; //pikim lause antud hetkel String rida=sisse.readLine(); while(rida!=null){ StringTokenizer st=new StringTokenizer(rida, " "); while(st.hasMoreTokens()){ String sona=st.nextToken(); pikim=pikim+sona+" "; aa++; if((sona.endsWith(".")) || (sona.endsWith("!")) || (sona.endsWith("?"))) { if (aa>meeles){ vordle=pikim; meeles=aa; } lause++; pikim=""; aa=0; } } rida=sisse.readLine(); } System.out.println("Kokku on "+lause+" lauset"); System.out.println("Enim sõnu oli lauses - "+vordle); sisse.close(); } }