In this
program user will enter any sentence and print all the character except the
vowels. In case of vowels print the character next to two places of it.
import
java.io.*;
class Sentence1
{
 String s1;
 int i,len;
 char ch;
 BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
 public void take Sentence1() throws Exception
 {
  System.out.println("Enter the
Sentence:");
  s1=br.readLine();
  len=s1.length();
  for(i=0;i< len;i++)
  {
   ch=Character.toLowerCase(s1.charAt(i));
   switch(ch)
   {
    case 'a':
    case 'e':
    case 'i':
    case 'o':
    case 'u':
   System.out.print((char)(s1.charAt(i)+2));
   break;
   default:
   System.out.print(s1.charAt(i));
   }
   }
  }
   public static void main(String args[])throws
Exception
  {
   Sentence1 ob=new Sentence1();
   ob.take Sentence1();
   }
No comments:
Post a Comment