Answers

2015-08-19T07:35:04+05:30

This Is a Certified Answer

×
Certified answers contain reliable, trustworthy information vouched for by a hand-picked team of experts. Brainly has millions of high quality answers, all of them carefully moderated by our most trusted community members, but certified answers are the finest of the finest.

// the syntax needs to be correctly written.  this is pseudo code...
//  tokensplit.java   file

package  .....;
import java.util.Scanner;
import java.io.IOException;
import java.util.lang;

public   class  demo {

    public static void main (String args[])  {

        String  longest, inpStr, str ;
        int cnt = 0, wordNumber = 0, lineNumber = 0;

        // read the input string..
       Scanner     inpStr  = new  Scanner (System.in);
       String delims = "[ .,?\\n\\t()]+" ;     // specify the word delimiter characters
       length = 0; 
       str = inpStr.nextLine();

       while (! str.isEmpty())  {
             lineNum++;
            String [] tokens = str.split (delims);
       
            for (String t  :  tokens)  {   // iterate over all tokens in str
                 wordNumber ++ ;
                 if (t.length() > length) {
                            length = t.length();   longest = t;
                  }
            } // for
           str = inpStr.nextLine();

      }  // while

      System.out.println("longest word: " + longest + "\t its length:  " + length + "in line: ", + lineNum + "  word number: " + wordNum);

} // class demo



1 5 1
click on thanks button above please