SHARE
TWEET

Untitled

advictoriam Jan 8th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top