Posts

Showing posts with the label vowels

mathajax

Java program Vowels and Consonants splitter - switch case char

The java code splits a string into two string object containing vowels and consonants character.On executing the code, an input has a string and it is converted into array of char. and then each character is passed into switch case to check whether it is a vowel or consonant and stored into a string object separately. import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class SwitchCase { public static void main(String[] args) throws IOException { InputStreamReader dis = new InputStreamReader ( System.in ); BufferedReader br = new BufferedReader(dis); String tstr = "Enter a string sentence to split vowels and consonants" ; System.out.println(tstr); String arg1 =br.readLine(); char carr[]= arg1.toLowerCase().toCharArray(); StringBuffer vowels= new StringBuffer(); StringBuffer consnt= new StringBuffer(); ...