### 문제 A, E, I, O, U를 모음이라고 가정했을때, 입력으로 들어온 문자열이 몇개의 모음과 자음으로 구성되어 있는지 출력하는 프로그램을 작성하세요. ### 입력 예 ``` 2 Programming is fun Hello World ``` ### 출력 예 ``` Programming is fun: 5 11 Hello World: 3 7 ``` ### 힌트 `Scanner` 클래스를 사용하여 키보드로부터 입력을 받아주세요. ``` Scanner input = new Scanner(System.in); int n = input.nextInt(); // 정수값 입력 String str = input.next(); // 문자열 입력 ``` `for`문과 `switch` 구문을 사용하여 모음과 자음의 개수를 세어주세요 ``` for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) { case 'a': case 'e': ... break; default: ... break; } } ```
``` package 자음과모음몇개인가; import java.util.Scanner; public class 자음과모음몇개인가 { public static void main(String[] args) { String a; int b, c = 0, z = 0; System.out.print("글자를 입력하세요 : "); Scanner sc = new Scanner(System.in); a = sc.nextLine(); for (int i = 0; i < a.length(); i++) { if (a.charAt(i) == 'a' || a.charAt(i) == 'e' || a.charAt(i) == 'i' || a.charAt(i) == 'o' || a.charAt(i) == 'u' ) { c++; } else if (a.charAt(i) == ' ') { z++; } } b = a.length() - z - c; System.out.println("자음개수는 " + b + "개 이고, 모음개수" + c + "개 이다."); } } ```