Advertisement
Kancho

Count_Vowels

Mar 25th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Vowels {
  4. public static void main(String[] args) {
  5.  
  6. Scanner sc = new Scanner(System.in);
  7. System.out.print("Some text: ");
  8. String someText = sc.nextLine().toLowerCase();
  9.  
  10. int count = 0;
  11. for (int i = 0; i < someText.length(); i++) {
  12. if (isVowel(someText.charAt(i))){
  13. count ++;
  14. System.out.println(someText.charAt(i));
  15. }
  16. }
  17.  
  18. System.out.println(count);
  19. }
  20. public static boolean isVowel(char text){
  21. if( "aeouiy".indexOf(text) != -1){
  22. return true;
  23. }
  24. return false;
  25. }
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement