Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Added: Dec 10, 2020 8:28 PM
Views: 3
Tags: string
  1. public class Main {
  2.  
  3.     public static void main(String[] args) {
  4.         System.out.println(nurVokale("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua."));
  5.     }
  6.     public static String nurVokale (String s){
  7.         String nospace = s.replace(" ", "");
  8.         String nocomma = nospace.replace(",", "").replace(".","");
  9.         String clean = nocomma.toLowerCase();
  10.         System.out.println("Eingabe-String: " + clean);
  11.         String valid = "aeiou";
  12.         String output = "";
  13.  
  14.         for (int i = 0; i <clean.length(); i++) {
  15.             char c = clean.charAt(i);
  16.             if(valid.contains("" + c)){
  17.                 output += c;
  18.             }
  19.  
  20.         }
  21.         return output;
  22.     }
  23. }
  24.