Page 258 - computer science (868) class 11
P. 258

Examples:
                     Country name:         INDIA
                     Output:               INDIA - TAJ MAHAL
                     Country name:         USA
                     Output:               Sorry not found!
                 21.  Write a program in Java to input two words and print the common alphabets in them.
                     Sample Input:
                     Enter 1st word    :  INDIA
                     Enter 2nd word    :  DELHI
                     Sample Output:
                     Common ALPHABETS  :  I,D
                 22.  Write a program in Java to accept a sentence, then convert each character to a second next character. The character A becomes
                    C and Z becomes B and so on.
                 23.  A class TheString accepts a string of a maximum of 100 characters with only one blank space between the words.
                     Some of the members of the class are as follows:
                     Class name        :  TheString
                     Data Members/Instance variables
                     str               :   to store a string
                     len               :   integer to store the length of the string
                     wordcount         :   integer to store the number of words
                     cons              :   integer to store the number of consonants
                     Member Functions/methods
                     TheString()       :   default constructor to initialize the data members
                     TheString(String ds)   :   parameterized constructor to assign str=ds
                     void countFreq()   :     to count the number of words and the number of consonants and store them in wordcount and cons
                                          respectively
                     void Display()    :   to display the original string, along with the number of words and the number of consonants
                     Specify the class TheString giving the details of the constructors, void countFreq() and void Display(). Define the main() function
                    to create an object and call the methods accordingly to perform the task.
                 24.  Design a class sortword with the following specifications:
                     Data Members
                     String txt        :   to store the word
                     int len           :   length of the word
                     Member Methods
                     sortword()        :   default constructor
                     void readtxt()    :   accepts the word
                     void sorttxt()    :   sorts the word in alphabetic order of characters using the bubble sort technique
                     void display()    :   displays the changed string
                 25.  Write a program in Java to accept a string, which includes some special characters like punctuation marks such as full stop,
                    comma, semicolon, etc. Display the string in reversed order without using punctuation marks.
                     Sample Input: ‘Directed to work’, ‘controlled’, and ‘Emotions’
                     Sample Output: Emotions and controlled work to directed
                 26.  Write a program in Java to enter certain alphabets in a 2D array mxn. Display the elements of the matrix. Replace all the vowels
                    of the matrix with the ‘*’. Display the new matrix.
                     Sample input:
                      w     E    d
                       r    T    u
                       k    J    u





                256256  Touchpad Computer Science-XI
   253   254   255   256   257   258   259   260   261   262   263