Page 253 - Computer science 868 Class 12
P. 253
8 int min=len,max=0;
9 String shortest_word="", longest_word="", word="";
10 while(start_index<len)
11 {
12 last_index=str.indexOf(" ", start_index);
13 word=str.substring(start_index,last_index);
14 l= word.length();
15 if(l<min) {
16 min=l;
17 shortest_word=word;
18 }//if ends
19 if(l>max)
20 {
21 max=l;
22 longest_word=word;
23 }//if ends
24 start_index=last_index+1;
25 }//loop ends
26 System.out.println("Shortest word = "+ shortest_word+" with length
"+min);
27 System.out.println("Longest word = "+longest_word+" with length "+max);
28 }//method ends
29 void main()
30 {
31 find_word("India is a big country");
32 }
33 } //class ends
The output of the preceding program is as follows:
Area of Rectangle : 8
Area of Square : 25
Area of Circle : 38.4895
251
Methods 251

