Back To Java User Defined Methods Index
//program to create a function that check whether character passed to it as argument is vowel or not using switch case statement class chvowel { public void cvowel(char ch) { switch(ch) { case 'a': System.out.println("you entered a vowel"); break; case 'e': System.out.println("you entered a vowel"); break; case 'i': System.out.println("you entered a vowel"); break; case 'o': System.out.println("you entered a vowel"); break; case 'u': System.out.println("you entered a vowel"); break; default: System.out.println("please enter a vowel (a,e,i,o,u)"); } } } public class checkvowel { public static void main(String[] args) { chvowel ob=new chvowel(); ob.cvowel('a'); } }