From db51648cfb3a710ced4dea4a9cd6f528beb43e24 Mon Sep 17 00:00:00 2001 From: Jens Albrecht <jens.albrecht@th-nuernberg.de> Date: Fri, 17 Jan 2025 07:50:24 +0100 Subject: [PATCH] . --- .../DoWhile.cs" | 13 ++++++++++ ...41025_Do_While_Qu\303\244lschleife.csproj" | 10 +++++++ .../Fakult\303\244t.cs" | 26 +++++++++++++++++++ .../VL241028_Fakult\303\244tsfunktion.csproj" | 10 +++++++ VL250113_SyntaxChecker/SyntaxChecker.cs | 2 +- 5 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 "VL241025_Do_While_Qua\314\210lschleife/DoWhile.cs" create mode 100644 "VL241025_Do_While_Qua\314\210lschleife/VL241025_Do_While_Qu\303\244lschleife.csproj" create mode 100644 "VL241028_Fakulta\314\210tsfunktion/Fakult\303\244t.cs" create mode 100644 "VL241028_Fakulta\314\210tsfunktion/VL241028_Fakult\303\244tsfunktion.csproj" diff --git "a/VL241025_Do_While_Qua\314\210lschleife/DoWhile.cs" "b/VL241025_Do_While_Qua\314\210lschleife/DoWhile.cs" new file mode 100644 index 0000000..75b3e79 --- /dev/null +++ "b/VL241025_Do_While_Qua\314\210lschleife/DoWhile.cs" @@ -0,0 +1,13 @@ +bool eingabeGueltig; + +do +{ + Console.Write("1 oder 2 eingeben: "); + string eingabe = Console.ReadLine()!; + + eingabeGueltig = (eingabe == "1" || eingabe == "2"); + if (!eingabeGueltig) + Console.WriteLine("Falsche Eingabe. Wiederhole."); + +} while (!eingabeGueltig); + diff --git "a/VL241025_Do_While_Qua\314\210lschleife/VL241025_Do_While_Qu\303\244lschleife.csproj" "b/VL241025_Do_While_Qua\314\210lschleife/VL241025_Do_While_Qu\303\244lschleife.csproj" new file mode 100644 index 0000000..206b89a --- /dev/null +++ "b/VL241025_Do_While_Qua\314\210lschleife/VL241025_Do_While_Qu\303\244lschleife.csproj" @@ -0,0 +1,10 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <OutputType>Exe</OutputType> + <TargetFramework>net8.0</TargetFramework> + <ImplicitUsings>enable</ImplicitUsings> + <Nullable>enable</Nullable> + </PropertyGroup> + +</Project> diff --git "a/VL241028_Fakulta\314\210tsfunktion/Fakult\303\244t.cs" "b/VL241028_Fakulta\314\210tsfunktion/Fakult\303\244t.cs" new file mode 100644 index 0000000..301a5b9 --- /dev/null +++ "b/VL241028_Fakulta\314\210tsfunktion/Fakult\303\244t.cs" @@ -0,0 +1,26 @@ +class Program +{ + // Berechnung n! + static int Fak(int n) + { + int ergebnis = 1; + + for (int i = 1; i <= n; i++) + { + ergebnis *= i; + } + + return ergebnis; + } + + static void Main(string[] args) + { + // Erfrage Zahl + Console.Write("Zahl eingeben: "); + int zahl = Convert.ToInt32(Console.ReadLine()); + + // Gib zahl! aus + int fak = Fak(zahl); + Console.WriteLine($"{zahl}! = {fak}"); + } +} diff --git "a/VL241028_Fakulta\314\210tsfunktion/VL241028_Fakult\303\244tsfunktion.csproj" "b/VL241028_Fakulta\314\210tsfunktion/VL241028_Fakult\303\244tsfunktion.csproj" new file mode 100644 index 0000000..206b89a --- /dev/null +++ "b/VL241028_Fakulta\314\210tsfunktion/VL241028_Fakult\303\244tsfunktion.csproj" @@ -0,0 +1,10 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <OutputType>Exe</OutputType> + <TargetFramework>net8.0</TargetFramework> + <ImplicitUsings>enable</ImplicitUsings> + <Nullable>enable</Nullable> + </PropertyGroup> + +</Project> diff --git a/VL250113_SyntaxChecker/SyntaxChecker.cs b/VL250113_SyntaxChecker/SyntaxChecker.cs index 5660c7e..5a979f9 100644 --- a/VL250113_SyntaxChecker/SyntaxChecker.cs +++ b/VL250113_SyntaxChecker/SyntaxChecker.cs @@ -14,7 +14,7 @@ Stellen Sie sicher, dass am Ende alle Klammern geschlossen sind. Wenn kein Fehler auftrat, soll eine Erfolgsmeldung ausgegeben werden. */ -internal class Program +class Program { private static void Main(string[] args) { -- GitLab