diff --git a/.gitignore b/.gitignore index 4ce6fddec962ff3b86038d9939b6be5dfc1e6351..f2be78287bc79780373a93d1a980ad6b12d017dc 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 0000000000000000000000000000000000000000..40c60dd4c884340c455eab8a0020f7c681a4e76c --- /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 0000000000000000000000000000000000000000..37d32438c076dbb696429abfb634d9d864d9b29f --- /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 0000000000000000000000000000000000000000..bd01064e0f1047bea42dd7d7ed723186e36673be --- /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 0000000000000000000000000000000000000000..40c60dd4c884340c455eab8a0020f7c681a4e76c --- /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 0000000000000000000000000000000000000000..8356c25ff38ad0a6d606071f88177b2340a575f9 --- /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 0000000000000000000000000000000000000000..40c60dd4c884340c455eab8a0020f7c681a4e76c --- /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 0000000000000000000000000000000000000000..5d4b46f2ab961e8d57a5dd9bc6bdc150d14883f6 --- /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 0000000000000000000000000000000000000000..8998c76ad67232541a738ba1c0c12d205c02fc77 --- /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 0000000000000000000000000000000000000000..40c60dd4c884340c455eab8a0020f7c681a4e76c --- /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 0000000000000000000000000000000000000000..a7af38b0244dd3e17dd4427b4c65cf35590d50ce --- /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 0000000000000000000000000000000000000000..40c60dd4c884340c455eab8a0020f7c681a4e76c --- /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>