Page 316 - CA_Blue( J )_Class10
P. 316
4 String sen,word;
5 int count;
6 sentence()
7 {
8 sen="";
9 word="";
10 count=0;
11 }
13 void input()
14 {
15 Scanner sc= new Scanner(System.in);
16 System.out.print("Enter a sentence : ");
17 sen=sc.nextLine();
18 System.out.print("Enter the word to check : ");
19 word=sc.next();
20 }
21 void check()
22 {
23 int i,l;
24 char ch;
25 String tw="";
26 l=sen.length();
27 for(i=0;i<l;i++)
28 {
29 ch=sen.charAt(i);
30 if(ch!=' ')
31 {
32 tw=tw+ch;
33 }
34 else
35 {if(tw.equalsIgnoreCase(word))
36 {
37 count++;
38 }
314314 Touchpad Computer Applications-X

