From 329e0779c9081bf368b414004ba76552d637e4a8 Mon Sep 17 00:00:00 2001 From: "DESKTOP-4QQ7EF3\\elsam" Date: Wed, 26 Aug 2020 09:46:26 +0200 Subject: [PATCH 1/6] Initial commit - Session 02 --- .../Session02Exercise01.sln | 25 +++++++++++++++++++ .../Session02Exercise01/Program.cs | 12 +++++++++ .../Session02Exercise01.csproj | 8 ++++++ 3 files changed, 45 insertions(+) create mode 100644 Session02/Session02Exercise01/Session02Exercise01.sln create mode 100644 Session02/Session02Exercise01/Session02Exercise01/Program.cs create mode 100644 Session02/Session02Exercise01/Session02Exercise01/Session02Exercise01.csproj diff --git a/Session02/Session02Exercise01/Session02Exercise01.sln b/Session02/Session02Exercise01/Session02Exercise01.sln new file mode 100644 index 0000000..d0f51d3 --- /dev/null +++ b/Session02/Session02Exercise01/Session02Exercise01.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30413.136 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Session02Exercise01", "Session02Exercise01\Session02Exercise01.csproj", "{97C3BD0B-6DA0-4F7A-9312-D3D91717C86D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {97C3BD0B-6DA0-4F7A-9312-D3D91717C86D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {97C3BD0B-6DA0-4F7A-9312-D3D91717C86D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {97C3BD0B-6DA0-4F7A-9312-D3D91717C86D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {97C3BD0B-6DA0-4F7A-9312-D3D91717C86D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {738BCA5B-16ED-4CA3-9FB5-D31BF33DEE4B} + EndGlobalSection +EndGlobal diff --git a/Session02/Session02Exercise01/Session02Exercise01/Program.cs b/Session02/Session02Exercise01/Session02Exercise01/Program.cs new file mode 100644 index 0000000..a37fc8d --- /dev/null +++ b/Session02/Session02Exercise01/Session02Exercise01/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace Session02Exercise01 +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} diff --git a/Session02/Session02Exercise01/Session02Exercise01/Session02Exercise01.csproj b/Session02/Session02Exercise01/Session02Exercise01/Session02Exercise01.csproj new file mode 100644 index 0000000..c73e0d1 --- /dev/null +++ b/Session02/Session02Exercise01/Session02Exercise01/Session02Exercise01.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + From 7e804f6bccb00e5a7bbcfa4833cd92d6df4ebbcc Mon Sep 17 00:00:00 2001 From: "DESKTOP-4QQ7EF3\\elsam" Date: Wed, 26 Aug 2020 10:08:50 +0200 Subject: [PATCH 2/6] Testing integers --- Session02/Session02Exercise01/Session02Exercise01/Program.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Session02/Session02Exercise01/Session02Exercise01/Program.cs b/Session02/Session02Exercise01/Session02Exercise01/Program.cs index a37fc8d..2e80d4e 100644 --- a/Session02/Session02Exercise01/Session02Exercise01/Program.cs +++ b/Session02/Session02Exercise01/Session02Exercise01/Program.cs @@ -7,6 +7,10 @@ class Program static void Main(string[] args) { Console.WriteLine("Hello World!"); + + var integer = 0; + + Console.WriteLine("Integer is " + integer.ToString()); } } } From cd1b7246bb74957e9f60487e3fd8327b998a9434 Mon Sep 17 00:00:00 2001 From: "DESKTOP-4QQ7EF3\\elsam" Date: Wed, 26 Aug 2020 10:38:38 +0200 Subject: [PATCH 3/6] String test --- Session02/Session02Exercise01/Session02Exercise01/Program.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Session02/Session02Exercise01/Session02Exercise01/Program.cs b/Session02/Session02Exercise01/Session02Exercise01/Program.cs index a37fc8d..724d953 100644 --- a/Session02/Session02Exercise01/Session02Exercise01/Program.cs +++ b/Session02/Session02Exercise01/Session02Exercise01/Program.cs @@ -7,6 +7,10 @@ class Program static void Main(string[] args) { Console.WriteLine("Hello World!"); + + string stringValue = "MyStringValue"; + + Console.WriteLine("The value of stringValue is: " + stringValue); } } } From 447af5216ecb189fe47e721ba3ccecca603e8d8a Mon Sep 17 00:00:00 2001 From: "DESKTOP-4QQ7EF3\\elsam" Date: Wed, 26 Aug 2020 11:49:26 +0200 Subject: [PATCH 4/6] Initialising exercise02 --- .../Session02Exercise01.sln | 8 ++++++- .../Session02Exercise02/Program.cs | 23 +++++++++++++++++++ .../Session02Exercise02.csproj | 8 +++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 Session02/Session02Exercise01/Session02Exercise02/Program.cs create mode 100644 Session02/Session02Exercise01/Session02Exercise02/Session02Exercise02.csproj diff --git a/Session02/Session02Exercise01/Session02Exercise01.sln b/Session02/Session02Exercise01/Session02Exercise01.sln index d0f51d3..2f48c65 100644 --- a/Session02/Session02Exercise01/Session02Exercise01.sln +++ b/Session02/Session02Exercise01/Session02Exercise01.sln @@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.30413.136 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Session02Exercise01", "Session02Exercise01\Session02Exercise01.csproj", "{97C3BD0B-6DA0-4F7A-9312-D3D91717C86D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Session02Exercise01", "Session02Exercise01\Session02Exercise01.csproj", "{97C3BD0B-6DA0-4F7A-9312-D3D91717C86D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Session02Exercise02", "Session02Exercise02\Session02Exercise02.csproj", "{FF584B27-3E2A-4112-B8A2-3F165D4EAEF3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,6 +17,10 @@ Global {97C3BD0B-6DA0-4F7A-9312-D3D91717C86D}.Debug|Any CPU.Build.0 = Debug|Any CPU {97C3BD0B-6DA0-4F7A-9312-D3D91717C86D}.Release|Any CPU.ActiveCfg = Release|Any CPU {97C3BD0B-6DA0-4F7A-9312-D3D91717C86D}.Release|Any CPU.Build.0 = Release|Any CPU + {FF584B27-3E2A-4112-B8A2-3F165D4EAEF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FF584B27-3E2A-4112-B8A2-3F165D4EAEF3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FF584B27-3E2A-4112-B8A2-3F165D4EAEF3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FF584B27-3E2A-4112-B8A2-3F165D4EAEF3}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Session02/Session02Exercise01/Session02Exercise02/Program.cs b/Session02/Session02Exercise01/Session02Exercise02/Program.cs new file mode 100644 index 0000000..cbf83f5 --- /dev/null +++ b/Session02/Session02Exercise01/Session02Exercise02/Program.cs @@ -0,0 +1,23 @@ +using System; + +namespace Session02Exercise02 +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Do you want to enter your name? (y/n)?"); + var key = Console.ReadKey(); + + if (key.KeyChar == 'n') + return; + + Console.WriteLine("\nEnter your name:"); + var name = Console.ReadLine(); + + Console.WriteLine("Hello, " + name + "!"); + + Console.ReadKey(); + } + } +} diff --git a/Session02/Session02Exercise01/Session02Exercise02/Session02Exercise02.csproj b/Session02/Session02Exercise01/Session02Exercise02/Session02Exercise02.csproj new file mode 100644 index 0000000..c73e0d1 --- /dev/null +++ b/Session02/Session02Exercise01/Session02Exercise02/Session02Exercise02.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + From 2142f5d16ab5eb75d816e1a0f34f6337a6ca60c8 Mon Sep 17 00:00:00 2001 From: "DESKTOP-4QQ7EF3\\elsam" Date: Fri, 28 Aug 2020 13:08:56 +0200 Subject: [PATCH 5/6] Progress in number app --- session03/Session03/Session03.sln | 25 ++++++++++ .../Session03/Session03Nubers/Program.cs | 47 +++++++++++++++++++ .../Session03Nubers/Session03Nubers.csproj | 8 ++++ 3 files changed, 80 insertions(+) create mode 100644 session03/Session03/Session03.sln create mode 100644 session03/Session03/Session03Nubers/Program.cs create mode 100644 session03/Session03/Session03Nubers/Session03Nubers.csproj diff --git a/session03/Session03/Session03.sln b/session03/Session03/Session03.sln new file mode 100644 index 0000000..e800347 --- /dev/null +++ b/session03/Session03/Session03.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30413.136 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Session03Nubers", "Session03Nubers\Session03Nubers.csproj", "{B1DF6ABD-780F-41C5-BF00-5A6401285520}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B1DF6ABD-780F-41C5-BF00-5A6401285520}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B1DF6ABD-780F-41C5-BF00-5A6401285520}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B1DF6ABD-780F-41C5-BF00-5A6401285520}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B1DF6ABD-780F-41C5-BF00-5A6401285520}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A3790709-9AB5-49E2-A23A-837C0A667D35} + EndGlobalSection +EndGlobal diff --git a/session03/Session03/Session03Nubers/Program.cs b/session03/Session03/Session03Nubers/Program.cs new file mode 100644 index 0000000..2373f1f --- /dev/null +++ b/session03/Session03/Session03Nubers/Program.cs @@ -0,0 +1,47 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.Drawing; + +namespace Session03Nubers +{ + class Program + { + static void Main(string[] args) + { + //Konvertera ett antal siffror i en array. + //Räkna ut det högsta värdet, vilket som är det lägsta värdet och medelvärdet (snitt på alla siffror i arrayen). + Console.WriteLine("Ange ett antal siffror separerat med kommatecken:"); + + var input = Console.ReadLine(); + var inputArray = input.Split(",", StringSplitOptions.RemoveEmptyEntries); + double?[] numberArray = new double?[inputArray.Length]; + int sum = 0; + + + for (int i = 0; i < inputArray.Length; i++) + { + bool parsed = double.TryParse(inputArray[i], out double parsedValue); + + if (parsed == true) // (parsed) är samma sak som (parsed == true) + { + numberArray[i] = parsedValue; + } + + else + { + numberArray[i] = null; + } + + } + + foreach (int number in numberArray) + { + Console.WriteLine("Värde: " + number.ToString()); + sum += number; + + } + + Console.WriteLine("Medelvärdet är: " + XX / numberArray.Length); + } + } +} diff --git a/session03/Session03/Session03Nubers/Session03Nubers.csproj b/session03/Session03/Session03Nubers/Session03Nubers.csproj new file mode 100644 index 0000000..c73e0d1 --- /dev/null +++ b/session03/Session03/Session03Nubers/Session03Nubers.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + From dbd565836691bbdd158f32940fe99f77262b3954 Mon Sep 17 00:00:00 2001 From: "DESKTOP-4QQ7EF3\\elsam" Date: Fri, 28 Aug 2020 13:26:17 +0200 Subject: [PATCH 6/6] Process in numbers --- session03/Session03/Session03Nubers/Program.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/session03/Session03/Session03Nubers/Program.cs b/session03/Session03/Session03Nubers/Program.cs index 2373f1f..55d8c41 100644 --- a/session03/Session03/Session03Nubers/Program.cs +++ b/session03/Session03/Session03Nubers/Program.cs @@ -16,7 +16,7 @@ static void Main(string[] args) var inputArray = input.Split(",", StringSplitOptions.RemoveEmptyEntries); double?[] numberArray = new double?[inputArray.Length]; int sum = 0; - + for (int i = 0; i < inputArray.Length; i++) { @@ -37,11 +37,16 @@ static void Main(string[] args) foreach (int number in numberArray) { Console.WriteLine("Värde: " + number.ToString()); + + + sum += number; + } - - Console.WriteLine("Medelvärdet är: " + XX / numberArray.Length); + Console.WriteLine("Det högsta värdet är: " + ); + Console.WriteLine("Det lägsta värdet är: " + ); + Console.WriteLine("Medelvärdet är: " + sum / numberArray.Length); } } }