56 lines
1.2 KiB
C#
56 lines
1.2 KiB
C#
|
Console.WriteLine("Willkommen zu Aufgabe 3");
|
|||
|
|
|||
|
string[] stringArray = ["zählen", "beenden", "hilfe"];
|
|||
|
|
|||
|
bool running = true;
|
|||
|
while (running)
|
|||
|
{
|
|||
|
string input = Console.ReadLine();
|
|||
|
|
|||
|
switch (input)
|
|||
|
{
|
|||
|
case "zählen":
|
|||
|
Zaehler();
|
|||
|
break;
|
|||
|
|
|||
|
case "beenden":
|
|||
|
running = false;
|
|||
|
break;
|
|||
|
|
|||
|
case "hilfe":
|
|||
|
Console.WriteLine("Mögliche Befehle: ");
|
|||
|
foreach (string befehl in stringArray)
|
|||
|
{
|
|||
|
Console.WriteLine(befehl);
|
|||
|
}
|
|||
|
break;
|
|||
|
|
|||
|
default:
|
|||
|
Console.WriteLine("Tippen sie \"hilfe\" für die Befehlsübersicht");
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
static void Zaehler()
|
|||
|
{
|
|||
|
int minResult = 0;
|
|||
|
int maxResult = 0;
|
|||
|
|
|||
|
Console.WriteLine("Geben Sie einen minimalen Wert ein: ");
|
|||
|
int.TryParse(Console.ReadLine(), out minResult);
|
|||
|
Console.WriteLine("Geben Sie einen maximalen Wert ein: ");
|
|||
|
int.TryParse(Console.ReadLine(), out maxResult);
|
|||
|
|
|||
|
|
|||
|
if (minResult >= maxResult)
|
|||
|
{
|
|||
|
Console.WriteLine("Zählen nicht möglich");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
for (; minResult <= maxResult; minResult++)
|
|||
|
{
|
|||
|
Console.WriteLine(minResult);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|