Page 536 - Cs_withBlue_J_C11_Flipbook
P. 536

Program 19     A class modify has been defined to modify a word by bringing all the vowels in the word at
                               the beginning followed by the consonants.
                               Example: ORIGINAL becomes OIIARGNL
                               Some of the members of the class are given below.
                               Class name             :   modify
                               Data members/Instance variables
                               word                   :   to store a word
                               nwWord                 :   to store the rearranged word

                               Member functions/Methods
                               modify()               :   default constructor
                               void rWord()           :   to accept the word in uppercase
                               void fVowelConsonant()  :   finds the frequency of vowels and consonants in the
                                                         word and displays them with an appropriate message
                               void arrange()         :   rearranges the word by bringing the vowels at the beginning
                                                         followed by consonants

                               void show()            :   displays the original word along with the rearranged word
                               Specify  the  class  Rearrange, giving  details  of the  constructor, void  readWord(),  void
                               ffVowelConsonant(), void arrange() and void show(). Define the main() function to create an
                               object and call the functions accordingly to enable the task.

                 1       import java.util.*;

                 2       class modify
                 3       {
                 4           String word,nwWord;

                 5           modify()

                 6           {
                 7               word = "";
                 8               nwWord = "";

                 9           }
                10

                11           void readWord()
                12           {

                13               Scanner sc=new Scanner(System.in);
                14               System.out.print("Enter the word: ");

                15               word = sc.next();
                16           }

                17
                18           void fVowelConsonant()

                19           {



                534534  Touchpad Computer Science-XI
   531   532   533   534   535   536   537   538   539   540   541