Page 376 - Computer science 868 Class 12
P. 376
19 wordCount=0;
20 cons=0;
21 }
22
23 void countFreq()
24 {
25 int i;
26 char ch;
27 for(i=0;i<len;i++)
28 {
29 ch=str.charAt(i);
30 if(ch==' ')
31 wordCount++;
32 ch=Character.toUpperCase(ch);
33 if(ch>='A' && ch<='Z')
34 {
35 if("AEIOU".indexOf(ch)==-1)
36 {
37 cons++;
38 }
39 }
40 }
41 if(len>0)
42 wordCount++;
43 }
44
45 public void display()
46 {
47 System. out.println("Original String :"+str);
48 System.out.println("Number of words: "+wordCount);
49 System.out.println("Number of consonants:"+cons);
50 }
51
374374 Touchpad Computer Science-XII

