Page 676 - Computer science 868 Class 12
P. 676

Question 8.                                                                                           [10]
              A class Encode has been defined to replace only the vowels in a word by the next corresponding vowel and form a new word.
              i.e. A → E, E → I, I → O, O → U, U → A and a → e, e → i, i → o, o → u, and u → a
              Example:   Input  :      Institution
                       Output :     Onstotatoun
              Some of the members of the class are given below:
              Class name                                     :  Encode
              Data members/instance variables:
              word                                           :  to store a word
              length                                         :  integer to store the length of the word
              new_word                                       :  to store the encoded word
              Methods/Member functions:
              Encode()                                       :  default constructor to initialise data members with legal initial values
              void acceptWord()                              :  to accept a word
              void  nextVowel()                              :   to replace only the vowels from the word stored in ‘word’ by the next
                                                              corresponding vowel and to assign it to ‘newword’, with the remaining
                                                              alphabets unchanged
              void display()                                 :  to  display  the  original  word  along  with  the encrypted word
              Specify the class Encode giving details of the constructor(), void acceptWord(), void nextVowel() and void display(). Define a main()
              function to create an object and call the functions accordingly to enable the task.



                                                            SECTION – C
                                                        Answer any two questions.
                          Each program should be written in such a way that it clearly depicts the logic of the problem stepwise.
                       This can be achieved by using comments in the program and mnemonic names or pseudo codes for algorithms.
               The programs must be written in Java and the algorithms must be written in general/standard form, wherever required/specified.
                                                       (Flowcharts are not required.)


              Question 9.
              Shelf is a kind of data structure which can store elements with the restriction that an element can be added from the rear end and
              removed from the front end only.
              The details of the class Shelf are given below:
              Class name                                     :  Shelf
              Data members/instance variables:
              ele[ ]                                         :  array to hold decimal numbers
              lim                                            :  maximum limit of the shelf
              front                                          :  to point the index of the front end
              rear                                           :  to point the index of the rear end
              Methods/Member functions:
              Shelf(int n)                                   :  constructor  to  initialise rear=0, lim=n, front= 0 and
              void pushVal(double v)                         :   to push decimal numbers in the shelf at the rear end if possible, otherwise
                                                              display the message “SHELF IS FULL”
              double popVal()                                :   to remove and return the decimal number from the front end of the shelf
                                                              if any, else returns −999.99
              void display()                                 :  to display the elements of the shelf
              (i)   Specify the class Shelf giving details of the functions void pushVal(double) and [4] double popVal( ). Assume that the other functions
                 have been defined.
                   The main( ) function and algorithm need NOT be written.
              (ii)  Name the entity described above and state its principle.                                        [1]


                674674  Touchpad Computer Science-XII
   671   672   673   674   675   676   677   678   679   680   681