
Read a string from the user, your program counts the number of vowels in the text and have it report a sum of each vowel found as well as the number of spaces. Make it in two classes

import java.util.*;
class CountVowels {
public static void main(String[] args) throws Exception {
Scanner input = new Scanner(System.in);
System.out.print("Please enter string ");
System.out.println();
String str = input.nextLine();
String st = str;
char[] third = st.toCharArray();
for (int counter = 0; counter < third.length; counter++) {
char ch = third[counter];
int count = 0;
for (int i = 0; i < third.length; i++) {
if (ch == third[i])
count++;
}
boolean flag = false;
for (int j = counter - 1; j >= 0; j--) {
if (ch == third[j])
flag = true;
}
if (!flag) {
if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o'
|| ch == 'u' || ch == ' ') {
System.out.println("Character " + ch + " occurs " + count
+ " times ");
}
}
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.