C# :: Aufgabe #26 :: Lösung #2
11 Lösungen

#26
Vokale zählen in einem beliebigen Satz
Anfänger - C#
von Dome
- 28.12.2012 um 23:58 Uhr
Programmieren Sie ein Programm, welches die Anzahl aller Vokale in einem zuvor eingegebenen Satz ausgibt.
Optional wäre die Ausgabe wie oft welcher Vokal in dem Satz vorhanden ist.
Optional wäre die Ausgabe wie oft welcher Vokal in dem Satz vorhanden ist.
Konsolenausgabe:
Geben Sie einen Satz ein :
Dies ist ein toller Satz.
Anzahl der Vokale : 8
A: 1
E: 3
I: 3
O: 1
U: 0
#2

von B.Denger (730 Punkte)
- 03.09.2013 um 12:09 Uhr

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace FakultätVonN { class Program { static void Main(string[] args) { Console.WriteLine("Geben sie einen Satz/Wort ein, dessen Vokale gezählt werden sollen"); string eingabe = Console.ReadLine(); int countA = eingabe.Split('A','a').Length - 1; int countE = eingabe.Split('E','e').Length - 1; int countI = eingabe.Split('I','i').Length - 1; int countO = eingabe.Split('O','o').Length - 1; int countU = eingabe.Split('U','u').Length - 1; int countAll = eingabe.Split('A', 'a', 'E', 'e', 'I', 'i', 'O', 'o', 'U', 'u').Length - 1; Console.WriteLine("Vokale Insgesamt : " + countAll); Console.WriteLine("A,a : " + countA); Console.WriteLine("E,e : " + countE); Console.WriteLine("I,i : " + countI); Console.WriteLine("O,o : " + countO); Console.WriteLine("U,u : " + countU); Console.ReadLine(); } } }
Kommentare:
Für diese Lösung gibt es noch keinen Kommentar
Seite 1 von 0
1