Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /**
- Reads a string and prints out all vowels contained in that string.
- Vowels are A E I O U a e i o u.
- Input: the value of s, a string
- Output: a string containing all the vowels in s,
- in the order in which they appear in s
- */
- public class GetVowels
- {
- public static void main(String[] args)
- {
- String r = "";
- Scanner in = new Scanner(System.in);
- String s = in.nextLine();
- String vowels = "aeiouAEIOU";
- for(int i = 0; i < s.length(); i++)
- {
- if(vowels.indexOf(s.charAt(i)) != -1){r += s.charAt(i);}
- }
- System.out.println(r);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement