Page 498 - computer science (868) class 11
P. 498
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
496496 Touchpad Computer Science-XI

