How to get output, if I want to count each vowels character in lowercase and uppercase. The output must print the following lines, inserting the number of appearances of vowel in lowercase and uppercase and the total appearances.
A:_lowercase,_uppercase, _total
E:_lowercase,_uppercase, _total
I:_lowercase,_uppercase, _total
O:_lowercase,_uppercase, _total
U:_lowercase,_uppercase, _total
Here is my code:
import java.util.Scanner;
public class vowelcnt {
public static void main(String args[]){
Scanner keyboard = new Scanner(System.in);
System.out.println("Give a string ");
String input=keyboard.nextLine();
char []chars=input.toCharArray();
int upperCase = 0;
int lowerCase = 0;
int vowelcount=0;
for(char c : chars) {
switch(c){
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
vowelcount++;
lowerCase++;
break;
case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
vowelcount++;
upperCase++;
break;
}
}
System.out.printf("A: %d Lowercase, %d Uppercase,",lowerCase,upperCase,vowelcount);
System.out.printf("%d Total",vowelcount);
}
}