Page 436 - Computer science 868 Class 12
P. 436

Specify the class CalSeries giving details of the constructor, void input(), int power(int, int) and void cal(). Define the main()
                    method to create an object and call the member functions accordingly to enable the task.
                 11.  A class ToWord is defined to print the digits of a number in words. Example:
                     1567 will be printed as ONE FIVE SIX SEVEN
                     298 will be printed as TWO NINE EIGHT
                     Some of the members of the class are given below.
                     Class name                       :  ToWord
                     Data Members/Instance variables
                     num                              :  integer to store value of num
                     Methods/Member functions
                     ToWord()                         :  default constructor
                     void input()                     :  to accept the value of num
                     void print(int n)                :  prints the digits of the numbers in word using recursive technique
                    Specify the class ToWord giving details of the constructor, void input(), void print(int) Define the main() method to create an
                    object and call the member functions accordingly to enable the task.
                 12.  A class Encode is defined to convert a sentence entered in upper case to its encoded form as follows:
                     Vowels are replaced by * (astericks)
                     Consonants by their next occurring alphabet like B with C, C with D , D with E .... Z with A.
                     Other characters remains unchanged e.g., The sentence COVID 19 will be encoded to D*W*E 19
                     Some of the members of the class are given below.
                     Class name                       :   Encode
                     Data Members/Instance variables
                     sen                              :  to store any sentence
                     esen                             :  to store the encoded sentence
                     Methods/Member functions
                     Encode()                         :  default constructor
                     void input()                     :  to accept the value of num
                     void change(String s, int p)     :  to encode the sentence ‘s’ to the form described above using recursive technique
                                                         and store in variable esen, here ‘p’ denotes index position
                     Specify the class Encode giving details of the constructor, void input(), void change(String, int). Define the main() method to
                    create an object and call the member functions accordingly to enable the task.
                 13.  A class called Count is defined to find the frequency of the word ‘and’ in a given sentence.
                    Example: If the sentence is:
                     Raj and Ravi went to the concert and had fun.
                     Then frequency of ‘and’ is 2.
                     Assume that the words can be in upper case, lower case or mixed case.
                     Some of the members of the class are given below.
                     Class name                       :   Count
                     Data Members/Instance variables
                     line                             :  to store any sentence
                     Methods/Member functions
                     Count()                          :  default constructor
                     void input()                     :  to accept sentence in variable line
                     int cal(String s)                :  using recursive technique, counts and returns how many times ‘and’ or ‘And’ or
                                                         ‘AND’ occurs in the sentence.
                     void print()                     :  calls int cal(String) and prints the frequency with appropriate message
                     Specify the class ToWord giving details of the constructor, void input(), int cal(String) and void print(). Define the main() method
                    to create an object and call the member functions accordingly to enable the task.



                434434  Touchpad Computer Science-XII
   431   432   433   434   435   436   437   438   439   440   441