Write a for loop that will loop through every letter of the input and print out just the vowels.
Sample input/outputs
In: howdyho out:oo
In: huehuehuehue out:ueueueue
In: poopoo what idk what im doing out:ooooaiaioi |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
class Main {
public static void main(String[] args) {
Scanner inp = new Scanner(System.in);
System.out.print("In:");
String word = inp.nextLine();
//write your code below
char [] vowels= {'a','e','i','o','u'};
for(int i=0;i<word.length();i++) {
for(int j=0;j<5;j++) {
if(word.charAt(i)==vowels[j]) {
System.out.print(vowels[j]);
}
}
}
}
}
|
반응형
'Java_beginner(Repl.it) > Auto-Graded-Course(AP CS A)' 카테고리의 다른 글
025 - Further For Loop Practice 1 (ascending) (0) | 2019.12.07 |
---|---|
024 - For Loop 6 (optional) (0) | 2019.12.07 |
022 - For Loops 4 (0) | 2019.11.30 |
021 - For Loops 3 (0) | 2019.11.30 |
020 - For Loops 2 (0) | 2019.11.30 |