Page 612 - ComputerScience_Class_11
P. 612
24 wd=st.nextToken();
25 if(wd.length()>len1)
26 {
27 len1=wd.length();
28 large=wd;
29 }
30 if(wd.length() < len2)
31 {
32 len2=wd.length();
33 small=wd;
34 }
35 }//loop ends
36 System.out.println("Word with maximum length="+large);
37 System.out.println("And it’s length="+large.length());
38 System.out.println("Word with minimum length="+small);
39 System.out.println("And it’s length="+small.length());
40 }//methods ends
41 public static void main(String[] args)
42 {
43 largesmall obj = new largesmall();
44 obj.input();
45 obj.findlargesmall();
46 }
47 }//class ends
The output of the preceding program is as follows:
BlueJ: Terminal Window - Java
Options
Enter a Sentence : The current stage of my book is final.
Given Sentence : The current stage of my book is final.
Word with maximum length=current
And it’s length=7
Word with minimum length=of
And it’s length=2
610 Touchpad Computer Science (Ver. 3.0)-XI

