Advertisement
advictoriam

Untitled

Jan 8th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.66 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. /**
  4.    Reads a string and prints out all vowels contained in that string.
  5.    Vowels are A E I O U a e i o u.
  6.  
  7.    Input: the value of s, a string
  8.    Output: a string containing all the vowels in s,
  9.       in the order in which they appear in s
  10. */
  11. public class GetVowels
  12. {
  13.    public static void main(String[] args)
  14.    {
  15.       String r = "";
  16.      
  17.       Scanner in = new Scanner(System.in);
  18.       String s = in.nextLine();
  19.      
  20.       String vowels = "aeiouAEIOU";
  21.       for(int i = 0; i < s.length(); i++)
  22.       {
  23.          if(vowels.indexOf(s.charAt(i)) != -1){r += s.charAt(i);}
  24.       }
  25.  
  26.       System.out.println(r);
  27.    }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement