string vowels program in java

Solutions on MaxInterview for string vowels program in java by the best coders in the world

showing results for - "string vowels program in java"
Alessandro
13 Jul 2017
1String str = "hello";
2String vowels = "aeiou";
3
4for(char c : str) if(vowels.contains(c)) System.out.println(c + "");
Tommaso
12 Jan 2018
1import java.util.Scanner;
2import java.util.*;
3
4class Test{
5    
6    public static boolean isVowel(char ch){
7        if(ch == 'A' || ch == 'a' || ch == 'E' || ch == 'e' || ch == 'i' || ch == 'I' || ch == 'o' || ch == 'O' || ch == 'u' || ch == 'U'){
8            return true;
9        }
10        return false;
11    }
12    
13    public static void main(String args[]){
14        
15        Scanner scan = new Scanner(System.in);
16        List<String> arr = new ArrayList<String>();
17        String str = scan.nextLine();
18        String words[] = str.split("\\s");
19        
20        for(String k: words){
21            boolean flag = false;
22            boolean f1 = true;
23            boolean f2 = true;
24            if(k.length()<=2){
25                continue;
26            }
27            for(int i = 0 ; i < k.length() ; i = i + 2){
28                if(isVowel(k.charAt(i))==false){
29                    f1 = false;
30                    break;
31                }
32            }
33            for(int i = 1 ; i < k.length() ; i = i + 2){
34                if(isVowel(k.charAt(i))==false){
35                    f2 = false;
36                    break;
37                }
38            }
39            if(f1 == true || f2 == true){
40                flag = true;
41            }
42            if(flag == true){
43                arr.add(k);
44            }
45        }
46        if(arr.size()==0){
47            System.out.print(-1);
48        }
49        else{
50            for(int i = 0 ; i < arr.size() ; i++)
51            {
52                System.out.print(arr.get(i) + " ");
53            }
54        }
55        scan.close();
56    }
57    
58}
queries leading to this page
java string and then prints out all the vowelsjava print vowels characters do whileprogram to print vowels in a string in javawrite a program on finding number of vowels in a string in javano of vowels in a string in javacalculate vowels in a string javavowels in a string javavowels in string in javacheck vowels in a string javajava program to find vowels and consonantshow to pick out vowels in a string in javaprint vowels in string javawrite a java program to find the number of letters 2c vowels and consonants in a given string by using method program to print the vowels in a given sentance of length 3c 3d200 in javafind vowels and consonants in a string in javaprint consonants that are adjacent to vowels in string in javavowels in javajava program to check vowels in a stringvowels in java stringhow to find the vowels in a string in javajava check for vowelsprint only vowels from a string java java write a function that takes in a string and then prints out all the vowels in the stringfind vowels in string using stream javavowels code in javacheck is vowels in javastring vowels program in javafinding vowels in a string in javafind vowels in string javavowels javavowels check in string in javavowels pattern javajava print vowels characters how to find vowels in a string javajava program to print only vowels in a stringwrite a java program to find the number of vowels in a stringjava program to print vowels in a stringvowel program in javafind vowels javavowels program in javahow to check vowels in a string in javajava program to count vowels in the stringcheck vowels in string in javaopposite vowels java programcheck vowels in string javahow to check if there are all vowels in a string in javawrite a program to calculate number of vowels present in a string and print them javajava program to count vowels in a string inoutjava write a function that takes in a string and then prints out all the vowels in the stringstring vowels program in java