// Program 14: Recursive Character Classification import java.util.*; class Count { String st; int v, c, s, sp; Count() { st = ""; } void input() { Scanner sc = new Scanner(System.in); st = sc.nextLine(); } void Count_Char(String text, int pos) { if (pos == text.length()) { return; } char ch = Character.toUpperCase(text.charAt(pos)); if (ch >= '0' && ch <= '9') { throw new IllegalArgumentException("Digits not allowed"); } if (ch >= 'A' && ch <= 'Z') { if ("AEIOU".indexOf(ch) >= 0) { v++; } else { c++; } } else if (ch == ' ') { s++; } else { sp++; } Count_Char(text, pos + 1); } public static void main(String[] args) { Count ob = new Count(); ob.input(); for (int i = 0; i < ob.st.length(); i++) { char ch = ob.st.charAt(i); if (ch >= '0' && ch <= '9') { System.out.println("Invalid: digit found"); return; } } ob.Count_Char(ob.st, 0); System.out.println("Vowels=" + ob.v + " Consonants=" + ob.c); System.out.println("Spaces=" + ob.s + " Special=" + ob.sp); } }