Page 614 - ComputerScience_Class_11
P. 614
24 while(st.hasMoreTokens())
25 {
26 wd=st.nextToken();
27 nw="";
28 len=wd.length();
29 for(i=0;i<len;i++)
30 {
31 ch=wd.charAt(i);
32 nw=ch+nw;
33 }
34 nwsen=nwsen+(wd+nw)+" ";
35 }
36 }
37 void display()
38 {
39 System.out.println("Original Sentence : "+ sen);
40 System.out.println("New sentence : "+nwsen);
41 }
42 public static void main(String args[])
43 {
44 Palindrome ob=new Palindrome();
45 ob.input();
46 ob.convert();
47 ob.display();
48 }
49 }
The output of the preceding program is as follows:
BlueJ: Terminal Window - Java
Options
Enter sentence
We are the students of class Eleven
Original Sentence : We are the students of class Eleven
New sentence : WeeW areera theeht studentsstneduts offo classssalc ElevennevelE
612 Touchpad Computer Science (Ver. 3.0)-XI

