Advertisement
Kancho

Is_Vowel

Mar 30th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4.  
  5. public class Demo {
  6. public static void main(String[] args) throws IOException {
  7. BufferedReader rd =
  8. new BufferedReader(
  9. new InputStreamReader(System.in));
  10.  
  11. System.out.print("Enter some text: ");
  12. String text = rd.readLine().toLowerCase();
  13.  
  14. int count = 0;
  15. for (int i = 0; i < text.length() ; i++) {
  16. if (isVowel(text.charAt(i))) {
  17. count ++;
  18. System.out.println(text.charAt(i) + "; is vowel");
  19. }
  20. }
  21. System.out.println(count + ": is the number of vowels in " + text);
  22. }
  23.  
  24. private static boolean isVowel(char symbol) {
  25.  
  26. if ("aeiyou".indexOf(symbol) != -1) {
  27. return true;
  28. }
  29. return false;
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement