Skip to content

Commit ce151a8

Browse files
github-actionsgithub-actions
github-actions
authored and
github-actions
committed
Formatted with Google Java Formatter
1 parent 2e586b7 commit ce151a8

File tree

1 file changed

+38
-35
lines changed

1 file changed

+38
-35
lines changed

strings/CheckVowels.java

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,51 @@
11
package strings;
22

33
/**
4-
* Vowel Count is a system whereby character strings are placed in order based on the
5-
* position of the characters in the conventional ordering of an alphabet. Wikipedia:
4+
* Vowel Count is a system whereby character strings are placed in order based on the position of
5+
* the characters in the conventional ordering of an alphabet. Wikipedia:
66
* https://en.wikipedia.org/wiki/Alphabetical_order
77
*/
8-
class CheckVowels{
9-
public static void main(String[] args) {
10-
assert !hasVowels("This is a strings");
11-
assert hasVowels("Hello World");
12-
assert hasVowels("Java is fun");
13-
assert !hasVowels("123hi");
14-
assert hasVowels("Coding vs Programming");
15-
}
16-
8+
class CheckVowels {
9+
public static void main(String[] args) {
10+
assert !hasVowels("This is a strings");
11+
assert hasVowels("Hello World");
12+
assert hasVowels("Java is fun");
13+
assert !hasVowels("123hi");
14+
assert hasVowels("Coding vs Programming");
15+
}
16+
1717
/**
1818
* Check if a string is has vowels or not
1919
*
2020
* @param input a string
2121
* @return {@code true} if given string has vowels, otherwise {@code false}
2222
*/
23-
public static boolean hasVowels(String input){
24-
if(input.matches("[AEIOUaeiou]")){
25-
countVowels(input);
26-
return true;
27-
}
28-
return false;
23+
public static boolean hasVowels(String input) {
24+
if (input.matches("[AEIOUaeiou]")) {
25+
countVowels(input);
26+
return true;
2927
}
30-
/**
31-
* count the number of vowels
32-
*
33-
* @param input a string
34-
* prints the count of vowels
35-
*/
36-
public static void countVowels(String input){
37-
input.toLowerCase();
38-
int count=0;
39-
int i=0;
40-
while(i<input.length()){
41-
if(input.charAt(i)=='a' || input.charAt(i)=='e'||input.charAt(i)=='i'||input.charAt(i)=='o'||input.charAt(i)=='u' ){
42-
count++;
43-
}
44-
i++;
45-
}
46-
System.out.println(count);
28+
return false;
29+
}
30+
/**
31+
* count the number of vowels
32+
*
33+
* @param input a string prints the count of vowels
34+
*/
35+
public static void countVowels(String input) {
36+
input.toLowerCase();
37+
int count = 0;
38+
int i = 0;
39+
while (i < input.length()) {
40+
if (input.charAt(i) == 'a'
41+
|| input.charAt(i) == 'e'
42+
|| input.charAt(i) == 'i'
43+
|| input.charAt(i) == 'o'
44+
|| input.charAt(i) == 'u') {
45+
count++;
46+
}
47+
i++;
4748
}
48-
}
49+
System.out.println(count);
50+
}
51+
}

0 commit comments

Comments
 (0)