Giter Club home page Giter Club logo

uebung-043's Introduction

Uebung-043 -- Digit Filter

📎Angabe .pdf

📊 Lernziele:

  • ↳ Stringbearbeitung

🧮 Aufgabenstellung:

  • Schreiben Sie ein Programm, welches vom Benutzer einen beliebigen Text einliest und alle Ziffern
    extrahiert und diese anschließend in einer Ausgabe-Zeichenfolge sammelt.

  • Die Benutzereingaben dürfen im gesamten Programm nicht verändert werden und müssen erhalten bleiben.

  • Zur Lösung dieser Aufgabe dürfen Sie nicht die Standard-Methoden von String verwenden!


🔎 Ausgabe Bsp.

  • Benutzerschnittstelle:

    Beispiel:
    Eingabetext: Hallo Max, meine Telfonnummer ist 067854378923 innerhalb von Österreich!
    Ausgabetext: 067854378923

SPOILER Lösung :

🖥 Ausgabe:

Meine Ausgabe:
Ausgabe 📎

💾 C# - Programm:

👉 ausklappen 👈
namespace DigitFilter       //  
{                           //
  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

      const int ASCIIZERO = 48;
      /*----------------------------- VARIABLES -----------------------------*/
      string userInput;
      int cacheOut = 0; 
      /*-------------------------------- HEAD -------------------------------*/
      Console.Clear();
      Console.Write("\n                    Zahlen Filter                    " +
      /* cWidth: */ "\n=====================================================");

      /*---[in:]-------------------- PROMPT_USER ----------------------------*/
      Console.Write("\n Geben Sie einen Text ein, " +
                    "\n aus dem die Zahlen gefiltert werden sollen.  " +
                    "\n ");
      /*----------------------------- GET_INPUT -----------------------------*/
      userInput = Console.ReadLine();
      int[] cacheDigits = new int[userInput.Length];
      char[] inputDigits = new char[userInput.Length];

      for (int i = 0; i < userInput.Length; i++)
      {
        inputDigits[i] = userInput[i];

        if (inputDigits[i] >= '0' && inputDigits[i] <= '9')
        {
          // ASCII "48" = Dezimal "0"
          cacheOut = (cacheOut * 10) + (inputDigits[i] - ASCIIZERO);
        }
      }
      Console.Write("\n-----------------------------------------------------" +
                   $"\n Alle Ziffern: {cacheOut}" +
                    "\n=====================================================");
      /*-------------------------------- END --------------------------------*/
      Console.Write("\n Zum beenden Eingabetaste drücken..");
      Console.ReadLine();    //  wait for [enter]
      Console.Clear();       //
    }
  }
}

uebung-043's People

Contributors

ixi-enki avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.