Wednesday, September 4, 2019

BlueJ Program On Changing The Vowel Characters With * In A Sentence

This is a string manipulation BlueJ Program. User will enter any sentence and our BlueJ Program will change all occurrence of vowels (if present) with character '*'. 


import java.util.*;
class Search
{
    int i,len;
    String str1,str2="";
    Scanner sc=new Scanner(System.in);
public void take()
{    
    System.out.print("\nEnter the sentence: ");
     str1=sc.nextLine();        
 }
    public void show()
    {
        char ch;
        len=str1.length();
        for(i=0;i< len;i++)
        {
             ch=str1.charAt(i);
             switch(ch)
             {


                  case 'A':
                  case 'a':
                  case 'E':
                  case 'e':
                  case 'I':
                  case 'i':
                  case 'O':
                  case 'o':
                  case 'U':
                  case 'u':
                  ch='*';
                }
                str2=str2+ch;
            }
        
        System.out.println("\nModified Sentence: "+str2);
    }
      
    public static void main(String args[])
    {
        Search ob=new Search();
        ob.take();
        ob.show();
   }
 }


Related Post: BlueJ Programs on String/Sentence

No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner