From 4248725acf59768b6db6cee7723ecc5c459a43fd Mon Sep 17 00:00:00 2001
From: Jens Albrecht <jens.albrecht@th-nuernberg.de>
Date: Mon, 28 Oct 2024 15:34:40 +0100
Subject: [PATCH] .

---
 .gitignore                                    |  2 +
 For/For.csproj                                | 10 ++++
 For/Program.cs                                | 20 ++++++++
 Quadratzahlen/Program.cs                      | 26 ++++++++++
 Quadratzahlen/Quadratzahlen.csproj            | 10 ++++
 TemperaturUmrechner/Program.cs                |  8 +++
 .../TemperaturUmrechner.csproj                | 10 ++++
 Uebung03.sln                                  | 49 +++++++++++++++++++
 VereinsBeitrag/Program.cs                     | 25 ++++++++++
 VereinsBeitrag/VereinsBeitrag.csproj          | 10 ++++
 rotation/Program.cs                           | 17 +++++++
 rotation/Rotation.csproj                      | 10 ++++
 12 files changed, 197 insertions(+)
 create mode 100644 For/For.csproj
 create mode 100644 For/Program.cs
 create mode 100644 Quadratzahlen/Program.cs
 create mode 100644 Quadratzahlen/Quadratzahlen.csproj
 create mode 100644 TemperaturUmrechner/Program.cs
 create mode 100644 TemperaturUmrechner/TemperaturUmrechner.csproj
 create mode 100644 Uebung03.sln
 create mode 100644 VereinsBeitrag/Program.cs
 create mode 100644 VereinsBeitrag/VereinsBeitrag.csproj
 create mode 100644 rotation/Program.cs
 create mode 100644 rotation/Rotation.csproj

diff --git a/.gitignore b/.gitignore
index 4ce6fdd..f2be782 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,6 +29,8 @@ bld/
 
 # Visual Studio 2015/2017 cache/options directory
 .vs/
+# Visual Studio Code directory
+.vscode/
 # Uncomment if you have tasks that create the project's static files in wwwroot
 #wwwroot/
 
diff --git a/For/For.csproj b/For/For.csproj
new file mode 100644
index 0000000..40c60dd
--- /dev/null
+++ b/For/For.csproj
@@ -0,0 +1,10 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>net6.0</TargetFramework>
+    <ImplicitUsings>enable</ImplicitUsings>
+    <Nullable>enable</Nullable>
+  </PropertyGroup>
+
+</Project>
diff --git a/For/Program.cs b/For/Program.cs
new file mode 100644
index 0000000..37d3243
--- /dev/null
+++ b/For/Program.cs
@@ -0,0 +1,20 @@
+// a) Geben Sie die int-Zahlen von 3..77 aus
+for (int i = 3; i <= 77; i++)
+{
+    Console.Write(i + " ");
+}
+Console.WriteLine("\n");
+
+// b)	Geben Sie alle durch 5 teilbaren Zahlen von 0..1000 aus
+for (int i = 0; i < 1000; i += 5)
+{
+    Console.Write(i + " ");
+}
+Console.WriteLine("\n");
+
+// c)	Geben Sie in Dreierschritten von 100 abwärts jede positive Zahl aus.
+for (int i = 100; i > 0; i -= 3)
+{
+    Console.Write(i + " ");
+}
+
diff --git a/Quadratzahlen/Program.cs b/Quadratzahlen/Program.cs
new file mode 100644
index 0000000..bd01064
--- /dev/null
+++ b/Quadratzahlen/Program.cs
@@ -0,0 +1,26 @@
+Console.Write("Zahl eingeben: ");
+int zahl = Convert.ToInt32(Console.ReadLine());
+
+Console.Write("Quadratzahlen bis max. " + zahl + ": ");
+
+int quadrat = 1;
+int i = 1;
+
+// geht auch mit for-Schleife
+while (i * i <= zahl)
+{
+    // Es gibt verschiedene Varianten, das "Innere" der Schleife zu gestalten
+    // bzw. die Schleifenbedingung zu variieren. 
+    // Wichtig ist, dass bei Eingabe der Zahl "120" am Ende nicht mehr die 121 
+    // und zu Anfang auch nicht zweimal die 1 ausgegeben wird.
+    quadrat = i * i;
+
+    // Trick: Setze ein Komma vor allen Zahlen, außer der ersten
+    if (i > 1)
+        Console.Write(", ");
+    Console.Write(quadrat);
+
+    i++;
+}
+
+Console.ReadKey();
diff --git a/Quadratzahlen/Quadratzahlen.csproj b/Quadratzahlen/Quadratzahlen.csproj
new file mode 100644
index 0000000..40c60dd
--- /dev/null
+++ b/Quadratzahlen/Quadratzahlen.csproj
@@ -0,0 +1,10 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>net6.0</TargetFramework>
+    <ImplicitUsings>enable</ImplicitUsings>
+    <Nullable>enable</Nullable>
+  </PropertyGroup>
+
+</Project>
diff --git a/TemperaturUmrechner/Program.cs b/TemperaturUmrechner/Program.cs
new file mode 100644
index 0000000..8356c25
--- /dev/null
+++ b/TemperaturUmrechner/Program.cs
@@ -0,0 +1,8 @@
+Console.WriteLine(" °C   | °F");
+Console.WriteLine("------+------");
+for (int celsius = 0; celsius <= 100; celsius += 4)
+{
+    double fahrenheit = 9.0 / 5.0 * celsius + 32;
+    Console.WriteLine($"{celsius,5:f1} |{fahrenheit,5:f1}");
+}
+
diff --git a/TemperaturUmrechner/TemperaturUmrechner.csproj b/TemperaturUmrechner/TemperaturUmrechner.csproj
new file mode 100644
index 0000000..40c60dd
--- /dev/null
+++ b/TemperaturUmrechner/TemperaturUmrechner.csproj
@@ -0,0 +1,10 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>net6.0</TargetFramework>
+    <ImplicitUsings>enable</ImplicitUsings>
+    <Nullable>enable</Nullable>
+  </PropertyGroup>
+
+</Project>
diff --git a/Uebung03.sln b/Uebung03.sln
new file mode 100644
index 0000000..5d4b46f
--- /dev/null
+++ b/Uebung03.sln
@@ -0,0 +1,49 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.3.32901.215
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VereinsBeitrag", "VereinsBeitrag\VereinsBeitrag.csproj", "{40633F45-4BFC-4D80-8130-7F7C4560B6A2}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "For", "For\For.csproj", "{44C94BE8-660B-464E-8809-15C63FB19C6D}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Quadratzahlen", "Quadratzahlen\Quadratzahlen.csproj", "{6997E45A-89C5-4672-B5F6-109C197E9E3D}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TemperaturUmrechner", "TemperaturUmrechner\TemperaturUmrechner.csproj", "{EAA8D883-2A4F-4818-8567-AC7A6C558889}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rotation", "Rotation\Rotation.csproj", "{5719CD29-31BC-48BB-847F-7EE13E9EC8E9}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{40633F45-4BFC-4D80-8130-7F7C4560B6A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{40633F45-4BFC-4D80-8130-7F7C4560B6A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{40633F45-4BFC-4D80-8130-7F7C4560B6A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{40633F45-4BFC-4D80-8130-7F7C4560B6A2}.Release|Any CPU.Build.0 = Release|Any CPU
+		{44C94BE8-660B-464E-8809-15C63FB19C6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{44C94BE8-660B-464E-8809-15C63FB19C6D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{44C94BE8-660B-464E-8809-15C63FB19C6D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{44C94BE8-660B-464E-8809-15C63FB19C6D}.Release|Any CPU.Build.0 = Release|Any CPU
+		{6997E45A-89C5-4672-B5F6-109C197E9E3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{6997E45A-89C5-4672-B5F6-109C197E9E3D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{6997E45A-89C5-4672-B5F6-109C197E9E3D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{6997E45A-89C5-4672-B5F6-109C197E9E3D}.Release|Any CPU.Build.0 = Release|Any CPU
+		{EAA8D883-2A4F-4818-8567-AC7A6C558889}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{EAA8D883-2A4F-4818-8567-AC7A6C558889}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{EAA8D883-2A4F-4818-8567-AC7A6C558889}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{EAA8D883-2A4F-4818-8567-AC7A6C558889}.Release|Any CPU.Build.0 = Release|Any CPU
+		{5719CD29-31BC-48BB-847F-7EE13E9EC8E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{5719CD29-31BC-48BB-847F-7EE13E9EC8E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{5719CD29-31BC-48BB-847F-7EE13E9EC8E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{5719CD29-31BC-48BB-847F-7EE13E9EC8E9}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {201AC3B5-039F-4E06-81F4-0D97EA4565A5}
+	EndGlobalSection
+EndGlobal
diff --git a/VereinsBeitrag/Program.cs b/VereinsBeitrag/Program.cs
new file mode 100644
index 0000000..8998c76
--- /dev/null
+++ b/VereinsBeitrag/Program.cs
@@ -0,0 +1,25 @@
+Console.WriteLine("Beitragsrechnung für einen Verein");
+Console.WriteLine("=================================");
+Console.Write("Geben Sie Ihr Alter ein: ");
+int alter = Convert.ToInt32(Console.ReadLine());
+
+double beitrag;
+
+if (alter <= 6)
+    beitrag = 0;
+else if (alter <= 17)
+    beitrag = 30;
+else if (alter <= 65)
+{
+    Console.Write("Sind Sie erwerbslos (j/n): ");
+    string antwort = Console.ReadLine()!;
+    if (antwort == "j")
+        beitrag = 40;
+    else 
+        beitrag = 80;
+}
+else
+    beitrag = 50;
+
+Console.WriteLine($"Ihr Beitrag ist {beitrag} Euro.");
+
diff --git a/VereinsBeitrag/VereinsBeitrag.csproj b/VereinsBeitrag/VereinsBeitrag.csproj
new file mode 100644
index 0000000..40c60dd
--- /dev/null
+++ b/VereinsBeitrag/VereinsBeitrag.csproj
@@ -0,0 +1,10 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>net6.0</TargetFramework>
+    <ImplicitUsings>enable</ImplicitUsings>
+    <Nullable>enable</Nullable>
+  </PropertyGroup>
+
+</Project>
diff --git a/rotation/Program.cs b/rotation/Program.cs
new file mode 100644
index 0000000..a7af38b
--- /dev/null
+++ b/rotation/Program.cs
@@ -0,0 +1,17 @@
+Console.WriteLine("Bitte geben Sie drei Zahlen ein:");
+
+int a = Convert.ToInt32(Console.ReadLine());
+int b = Convert.ToInt32(Console.ReadLine());
+int c = Convert.ToInt32(Console.ReadLine());
+
+Console.WriteLine("Vor Rotation:");
+Console.WriteLine($"a = {a}, b = {b}, c = {c}");
+Console.WriteLine("Nach Rotation:");
+
+// Rotation
+int merker = a;
+a = b;
+b = c;
+c = merker;
+
+Console.WriteLine($"a = {a}, b = {b}, c = {c}");
diff --git a/rotation/Rotation.csproj b/rotation/Rotation.csproj
new file mode 100644
index 0000000..40c60dd
--- /dev/null
+++ b/rotation/Rotation.csproj
@@ -0,0 +1,10 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>net6.0</TargetFramework>
+    <ImplicitUsings>enable</ImplicitUsings>
+    <Nullable>enable</Nullable>
+  </PropertyGroup>
+
+</Project>
-- 
GitLab