Page 546 - Cs_withBlue_J_C11_Flipbook
P. 546
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()
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:
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
Variable Description
NAME TYPE DESCRIPTION
sen String To store the sentence
nwsen String To store the palindrome sentence
wd String To store word
nw String To store reverse of the word
544544 Touchpad Computer Science-XI

