Thursday, November 5, 2015

BlueJ Program On Changing Vowels In A Sentence To Its Next Character


In this program, the user will enter a string and all the vowels
in the string will be converted into it's next character.
Example
Input: This is a test
Output: Thjs js b tfst

import java.io.*;
class A
{
 String s1,s2;
 BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
 int i,len;
 char ch;
 public void take () throws Exception
 {
  System.out.println("Enter the sentence:");
  s1=br.readLine();
  len=s1.length();
  s2="";
  for(i=0;i< len;i++)
  {
  ch=s1.charAt(i);
  switch(Character.toUpperCase(ch))
  {
  case 'A':
  case 'E':
  case 'I':
  case 'O':
  case 'U':
    s2=s2+(char)(ch+1);
    break;
  default:
  s2=s2+ch;
 }
 }
 System.out.println("Input="+s1);
 System.out.println("Output="+s2);
 }
 public static void main(String args[])throws Exception
 {
 A ob=new A();
 ob.take();
 }
 }

Related Post: BlueJ Programs on String/Sentence

No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner