Page 462 - Cs_withBlue_J_C11_Flipbook
P. 462
15 return pos;
16 }
17 }
Piglatin class is as follows:
1 import Eleven.Vowel; // importing class
2 import java.util.*;
3 class Piglatin
4 {
5 String s;
6
7 void accept()
8 {
9 Scanner sc=new Scanner(System.in);
10 System.out.println("Enter the sentence");
11 s=sc.nextLine().toUpperCase();
12 }
13
14 void display()
15 {
16 String wo1,wo2,ns="";
17 int ps;
18 Vowel vo=new Vowel();
19 StringTokenizer st=new StringTokenizer(s," !.?,");
20 while(st.hasMoreTokens())
21 {
22 wo1=st.nextToken();
23 ps=vo.firstvowel(wo1); // method call of class Vowel in package Eleven
24 // converting words to piglatin form
25 if(ps==-1)
26 { wo2=wo1;}
27 else if(ps==0)
28 { wo2=wo1+"YAY";}
29 else
460460 Touchpad Computer Science-XI

