Page 638 - Computer science 868 Class 12
P. 638

double area()
              rectangl2.area()
              returned: double 9.0

              Name of Instance: circle1
              new Circle: 80

              double area()
              circle1.area()
              returned: double 20096.0



              PROGRAM ON STRING

                Program 25     Convert a sentence to Palindrome sentence
                               Class name                   :  palindrome
                               Data Members
                               String s,ps,w                :  To store sentence, palindromic sentence and word Int i
                               Member Function
                               palindrome()                 :  parameterised constructor
                               void input()                 :  to input a sentence
                               void convert()               :   to convert into a palindromic sentence as well as display
                                                               the sentence

                 1       import java.util.*;

                 2       class Palindrome
                 3       { String s,ps,w;

                 4         int l;
                 5       Palindrome()
                 6       { s="";ps="";}

                 7

                 8       void input()
                 9       { Scanner sc=new Scanner(System.in);
                10         System.out.println("Enter sentence");

                11       s=sc.nextLine();
                12       }

                13
                14       void convert()

                15       { StringTokenizer st=new StringTokenizer(s);
                16         String w1;

                17
                18         while(st.hasMoreTokens())



                636636  Touchpad Computer Science-XII
   633   634   635   636   637   638   639   640   641   642   643