Skip to content

IxI-Enki/Uebung-044

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Uebung-044 -- Vocal Filter

📎Angabe .pdf

📊 Lernziele:

  • ↳ Strings

🧮 Aufgabenstellung:

  • Das Programm extrahiert aus dem eingegebenen Text alle Vokale (Groß/Kleinschreibung ist egal).
  • Als Vokale sind nur a,e,i,o,u und A,E,I,O,U zu berücksichtigen.
  • Kommt ein Vokal mehrfach vor, ist nur das erste Vorkommen zu verwenden.

Orientieren Sie sich bei der Ausgabe an der Musterausgabe!


🔎 Ausgabe Bsp.

Musterausgabe
Ausgabebeispiel 📎

Testbeispiele
Testbeispiele: 📎

SPOILER Lösung :

🖥 Ausgabe:

Meine Ausgabe
Ausgabe 📎

💾 C# - Programm:

👉 ausklappen 👈
namespace FilterVocals      //  
{                           //
 public class Program      //
 {                         //
   static void Main()      //
   {
     ///*----------------------- console_settings ------------------------*///
     const int cWidth = 53;                     //  console width
     const int cHeight = 30;                    //  & height
     Console.SetWindowSize(cWidth, cHeight);    //
     Console.OutputEncoding = Encoding.UTF8;    //  Unicode Symbols

     /*----------------------------- VARIABLES -----------------------------*/
     string userInput,                       //  
            vocalCache = "",
            vocalCacheOut = "";
     char[] vocalLower = new char[5];
     vocalLower = ['a', 'e', 'i', 'o', 'u'];
     char[] vocalUpper = new char[5];
     vocalUpper = ['A', 'E', 'I', 'O', 'U'];

     int index;
     bool empty;

     /*-------------------------------- HEAD -------------------------------*/
     Console.Clear();
     Console.Write("\n             Vokale aus Text extrahieren             " +
     /* cWidth: */ "\n=====================================================");

     Console.Write("\n Text: ");
     userInput = Console.ReadLine();

     empty = (userInput.Length > 0) ? true : false;
     if (empty)
     {
       for (index = 0; index < userInput.Length; index++)
       {
         for (int i = 0; i < 5; i++)
         {
           if (userInput[index] == vocalLower[i] || userInput[index] == vocalUpper[i])
           {
             vocalCache = vocalCache + userInput[index];
             vocalLower[i] = ' ';
             vocalUpper[i] = ' ';
           }
         }
       }
       int length = vocalCache.Length;
       for (index = 0; length > index; index++)
       {
         if (vocalCache[index] != ' ')
         {
           vocalCacheOut = vocalCacheOut + vocalCache[index];
         }
       }
     }
     else
     { Console.Write("\n"); }

     Console.Write($"\n Der Text \"{userInput}\" enthält {vocalCacheOut.Length} Vokale: {vocalCacheOut}");

     /*-------------------------------- END --------------------------------*/
     Console.Write("\n Zum beenden Eingabetaste drücken..");
     Console.ReadLine();    //  wait for [enter]
     Console.Clear();       //
   }
 }
}

Releases

No releases published

Packages

No packages published

Languages