In this program, the vowel characters of any string will be shifted one character forward.
import java.io.*;
public class Str
{
String s1,s2="";
char ch;
int i,len;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
public void take() throws Exception
{
System.out.println("Enter the sentence:");
s1=br.readLine().toUpperCase();
len=s1.length();
for(i=0;i< len;i++)
{
ch=s1.charAt(i);
switch(ch)
{
case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
ch=(char)(ch+1);
}
s2=s2+ch;
}
}
void show()
{
System.out.println("Original sentence:"+s1);
System.out.println("Modified sentence:"+s2);
}
public static void main(String args[])throws Exception
{
Str ob=new Str();
ob.take();
ob.show();
}
}
No comments:
Post a Comment