From b246f28c6e8837ddb2fd0d02b9baeee82d085e35 Mon Sep 17 00:00:00 2001 From: Pyts Date: Wed, 26 Aug 2020 09:47:48 +0200 Subject: [PATCH 01/14] Initialize a commit. --- Session02/Session02.sln | 25 +++++++++++++++++++ Session02/Session02Exercise01/Program.cs | 13 ++++++++++ .../Session02Exercise01.csproj | 8 ++++++ 3 files changed, 46 insertions(+) create mode 100644 Session02/Session02.sln create mode 100644 Session02/Session02Exercise01/Program.cs create mode 100644 Session02/Session02Exercise01/Session02Exercise01.csproj diff --git a/Session02/Session02.sln b/Session02/Session02.sln new file mode 100644 index 0000000..6ede0f6 --- /dev/null +++ b/Session02/Session02.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30330.147 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Session02Exercise01", "Session02Exercise01\Session02Exercise01.csproj", "{7AD8F7EE-EE2F-4406-83B8-175E47A055BA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7AD8F7EE-EE2F-4406-83B8-175E47A055BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7AD8F7EE-EE2F-4406-83B8-175E47A055BA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7AD8F7EE-EE2F-4406-83B8-175E47A055BA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7AD8F7EE-EE2F-4406-83B8-175E47A055BA}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A01846C8-7967-4D9C-BFB6-B277CE9B5BFB} + EndGlobalSection +EndGlobal diff --git a/Session02/Session02Exercise01/Program.cs b/Session02/Session02Exercise01/Program.cs new file mode 100644 index 0000000..f99d981 --- /dev/null +++ b/Session02/Session02Exercise01/Program.cs @@ -0,0 +1,13 @@ +using System; + +namespace Session02Exercise01 +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + Console.ReadLine(); + } + } +} diff --git a/Session02/Session02Exercise01/Session02Exercise01.csproj b/Session02/Session02Exercise01/Session02Exercise01.csproj new file mode 100644 index 0000000..c73e0d1 --- /dev/null +++ b/Session02/Session02Exercise01/Session02Exercise01.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + From b6aaccac779af2274b527983b707c8e929f1f9f5 Mon Sep 17 00:00:00 2001 From: Pyts Date: Wed, 26 Aug 2020 09:57:39 +0200 Subject: [PATCH 02/14] Initialize commit. --- Session02/Session02Exercise01/Program.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Session02/Session02Exercise01/Program.cs b/Session02/Session02Exercise01/Program.cs index f99d981..b0cca60 100644 --- a/Session02/Session02Exercise01/Program.cs +++ b/Session02/Session02Exercise01/Program.cs @@ -7,7 +7,10 @@ class Program static void Main(string[] args) { Console.WriteLine("Hello World!"); + Console.WriteLine("Hello World!"); + Console.ReadLine(); + } } } From 1618ce9443be9dca3ac665d142c0474eefca0830 Mon Sep 17 00:00:00 2001 From: Pyts Date: Wed, 26 Aug 2020 09:59:46 +0200 Subject: [PATCH 03/14] Initailize commit3 --- Session02/Session02Exercise01/Program.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Session02/Session02Exercise01/Program.cs b/Session02/Session02Exercise01/Program.cs index b0cca60..3fb3c34 100644 --- a/Session02/Session02Exercise01/Program.cs +++ b/Session02/Session02Exercise01/Program.cs @@ -8,6 +8,8 @@ static void Main(string[] args) { Console.WriteLine("Hello World!"); Console.WriteLine("Hello World!"); + Console.WriteLine("Hello World!"); + Console.ReadLine(); From 0eea42592049fd9973d7140c0bf781d6c2e5cc88 Mon Sep 17 00:00:00 2001 From: Pyts Date: Wed, 26 Aug 2020 10:08:45 +0200 Subject: [PATCH 04/14] Testing intergers --- Session02/Session02Exercise01/Program.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Session02/Session02Exercise01/Program.cs b/Session02/Session02Exercise01/Program.cs index 3fb3c34..cf5358a 100644 --- a/Session02/Session02Exercise01/Program.cs +++ b/Session02/Session02Exercise01/Program.cs @@ -7,11 +7,10 @@ class Program static void Main(string[] args) { Console.WriteLine("Hello World!"); - Console.WriteLine("Hello World!"); - Console.WriteLine("Hello World!"); + var integer = 0; - Console.ReadLine(); + Console.WriteLine("Integer is " + integer.ToString()); } } From 86765571d1da4c60ccb63f89999f161f4fe411b1 Mon Sep 17 00:00:00 2001 From: TooOldForThisGit Date: Wed, 26 Aug 2020 10:38:46 +0200 Subject: [PATCH 05/14] Stringtest --- Session02/Session02Exercise01/Program.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Session02/Session02Exercise01/Program.cs b/Session02/Session02Exercise01/Program.cs index 3fb3c34..4f16a43 100644 --- a/Session02/Session02Exercise01/Program.cs +++ b/Session02/Session02Exercise01/Program.cs @@ -7,12 +7,10 @@ class Program static void Main(string[] args) { Console.WriteLine("Hello World!"); - Console.WriteLine("Hello World!"); - Console.WriteLine("Hello World!"); - - Console.ReadLine(); + string stringValue = "MyStringValue"; + Console.WriteLine("The value of stringValue is: " + stringValue) } } } From d2296f335d37d65a1ffbe05df6a9b25bae47cd41 Mon Sep 17 00:00:00 2001 From: TooOldForThisGit Date: Wed, 26 Aug 2020 10:39:36 +0200 Subject: [PATCH 06/14] Stringtest --- Session02/Session02Exercise01/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Session02/Session02Exercise01/Program.cs b/Session02/Session02Exercise01/Program.cs index 4f16a43..724d953 100644 --- a/Session02/Session02Exercise01/Program.cs +++ b/Session02/Session02Exercise01/Program.cs @@ -10,7 +10,7 @@ static void Main(string[] args) string stringValue = "MyStringValue"; - Console.WriteLine("The value of stringValue is: " + stringValue) + Console.WriteLine("The value of stringValue is: " + stringValue); } } } From dfb7d60ca7560f9f7296babe424195047eab914a Mon Sep 17 00:00:00 2001 From: TooOldForThisGit Date: Wed, 26 Aug 2020 11:49:10 +0200 Subject: [PATCH 07/14] Nameinput commit. --- Session02/Exercise01/Exercise01.csproj | 8 ++++++++ Session02/Exercise01/Nameprogram.cs | 24 ++++++++++++++++++++++++ Session02/Session02.sln | 8 +++++++- 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 Session02/Exercise01/Exercise01.csproj create mode 100644 Session02/Exercise01/Nameprogram.cs diff --git a/Session02/Exercise01/Exercise01.csproj b/Session02/Exercise01/Exercise01.csproj new file mode 100644 index 0000000..c73e0d1 --- /dev/null +++ b/Session02/Exercise01/Exercise01.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + diff --git a/Session02/Exercise01/Nameprogram.cs b/Session02/Exercise01/Nameprogram.cs new file mode 100644 index 0000000..a6eaba4 --- /dev/null +++ b/Session02/Exercise01/Nameprogram.cs @@ -0,0 +1,24 @@ +using System; + +namespace Exercise01 +{ + class Nameprogram + { + 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("Enter your name:"); + var name = Console.ReadLine(); + + Console.WriteLine("Hello, " + name); + Console.ReadKey(); + + + } + } +} diff --git a/Session02/Session02.sln b/Session02/Session02.sln index 6ede0f6..529ccbd 100644 --- a/Session02/Session02.sln +++ b/Session02/Session02.sln @@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.30330.147 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Session02Exercise01", "Session02Exercise01\Session02Exercise01.csproj", "{7AD8F7EE-EE2F-4406-83B8-175E47A055BA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Session02Exercise01", "Session02Exercise01\Session02Exercise01.csproj", "{7AD8F7EE-EE2F-4406-83B8-175E47A055BA}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Exercise01", "Exercise01\Exercise01.csproj", "{A006EB6B-4575-4218-8515-908D59C38027}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,6 +17,10 @@ Global {7AD8F7EE-EE2F-4406-83B8-175E47A055BA}.Debug|Any CPU.Build.0 = Debug|Any CPU {7AD8F7EE-EE2F-4406-83B8-175E47A055BA}.Release|Any CPU.ActiveCfg = Release|Any CPU {7AD8F7EE-EE2F-4406-83B8-175E47A055BA}.Release|Any CPU.Build.0 = Release|Any CPU + {A006EB6B-4575-4218-8515-908D59C38027}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A006EB6B-4575-4218-8515-908D59C38027}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A006EB6B-4575-4218-8515-908D59C38027}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A006EB6B-4575-4218-8515-908D59C38027}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From a82686afe9bcc17d264cd2e6956d4ec5a5d60ba8 Mon Sep 17 00:00:00 2001 From: TooOldForThisGit Date: Thu, 27 Aug 2020 00:39:33 +0200 Subject: [PATCH 08/14] Initialize commit - Session02 --- Session02/Exercise01/Nameprogram.cs | 1 - Session2/Session02/Session02.sln | 25 +++++++++++++++++++ .../Session02/Session02Exercise01/Program.cs | 12 +++++++++ .../Session02Exercise01.csproj | 8 ++++++ csharp-plus-2020 | 1 + sharp_projects | 1 + srctreeclone | 1 + 7 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 Session2/Session02/Session02.sln create mode 100644 Session2/Session02/Session02Exercise01/Program.cs create mode 100644 Session2/Session02/Session02Exercise01/Session02Exercise01.csproj create mode 160000 csharp-plus-2020 create mode 160000 sharp_projects create mode 160000 srctreeclone diff --git a/Session02/Exercise01/Nameprogram.cs b/Session02/Exercise01/Nameprogram.cs index a6eaba4..066d599 100644 --- a/Session02/Exercise01/Nameprogram.cs +++ b/Session02/Exercise01/Nameprogram.cs @@ -18,7 +18,6 @@ static void Main(string[] args) Console.WriteLine("Hello, " + name); Console.ReadKey(); - } } } diff --git a/Session2/Session02/Session02.sln b/Session2/Session02/Session02.sln new file mode 100644 index 0000000..d97404b --- /dev/null +++ b/Session2/Session02/Session02.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30330.147 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Session02Exercise01", "Session02Exercise01\Session02Exercise01.csproj", "{D43377BC-B59A-4BC3-9C2B-E8A1E15DECC3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D43377BC-B59A-4BC3-9C2B-E8A1E15DECC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D43377BC-B59A-4BC3-9C2B-E8A1E15DECC3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D43377BC-B59A-4BC3-9C2B-E8A1E15DECC3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D43377BC-B59A-4BC3-9C2B-E8A1E15DECC3}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {BE13223B-EA03-4564-8DF3-0ADFF6760509} + EndGlobalSection +EndGlobal diff --git a/Session2/Session02/Session02Exercise01/Program.cs b/Session2/Session02/Session02Exercise01/Program.cs new file mode 100644 index 0000000..a37fc8d --- /dev/null +++ b/Session2/Session02/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/Session2/Session02/Session02Exercise01/Session02Exercise01.csproj b/Session2/Session02/Session02Exercise01/Session02Exercise01.csproj new file mode 100644 index 0000000..c73e0d1 --- /dev/null +++ b/Session2/Session02/Session02Exercise01/Session02Exercise01.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + diff --git a/csharp-plus-2020 b/csharp-plus-2020 new file mode 160000 index 0000000..f0bd65b --- /dev/null +++ b/csharp-plus-2020 @@ -0,0 +1 @@ +Subproject commit f0bd65ba05e036d62fcc364a4576ff7bad2b442d diff --git a/sharp_projects b/sharp_projects new file mode 160000 index 0000000..dfb7d60 --- /dev/null +++ b/sharp_projects @@ -0,0 +1 @@ +Subproject commit dfb7d60ca7560f9f7296babe424195047eab914a diff --git a/srctreeclone b/srctreeclone new file mode 160000 index 0000000..f0bd65b --- /dev/null +++ b/srctreeclone @@ -0,0 +1 @@ +Subproject commit f0bd65ba05e036d62fcc364a4576ff7bad2b442d From 1a9340c240e5a30c35af4f9ea2f920a65a6426d1 Mon Sep 17 00:00:00 2001 From: TooOldForThisGit Date: Thu, 27 Aug 2020 11:15:17 +0200 Subject: [PATCH 09/14] Testing integer. --- Session2/Session02/Session02Exercise01/Program.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Session2/Session02/Session02Exercise01/Program.cs b/Session2/Session02/Session02Exercise01/Program.cs index a37fc8d..d7a983f 100644 --- a/Session2/Session02/Session02Exercise01/Program.cs +++ b/Session2/Session02/Session02Exercise01/Program.cs @@ -6,7 +6,11 @@ class Program { static void Main(string[] args) { - Console.WriteLine("Hello World!"); + Console.WriteLine("Hallå världen!"); + + var integer = 0; + + Console.WriteLine("Integer is: " + integer); } } } From a27e590c750ff0bed3acdef8d58a7665b119266e Mon Sep 17 00:00:00 2001 From: TooOldForThisGit Date: Thu, 27 Aug 2020 11:41:31 +0200 Subject: [PATCH 10/14] String test --- Session2/Session02/Session02Exercise01/Program.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Session2/Session02/Session02Exercise01/Program.cs b/Session2/Session02/Session02Exercise01/Program.cs index a37fc8d..b342f28 100644 --- a/Session2/Session02/Session02Exercise01/Program.cs +++ b/Session2/Session02/Session02Exercise01/Program.cs @@ -7,6 +7,10 @@ class Program static void Main(string[] args) { Console.WriteLine("Hello World!"); + + string stringValue = "Mystringvalue"; + + Console.WriteLine("value of my stringvalue: " + stringValue ); } } } From e11cde4d71da1776e5e23f060a5a8f8d6e7a2ef4 Mon Sep 17 00:00:00 2001 From: TooOldForThisGit Date: Fri, 28 Aug 2020 09:16:17 +0200 Subject: [PATCH 11/14] Session 03 - Exercises --- Session03/Session03.sln | 25 +++++++++++++++++++ Session03/Session03Exercise02/Program.cs | 22 ++++++++++++++++ .../Session03Exercise02.csproj | 8 ++++++ .../Session02/Session02Exercise01/Program.cs | 3 --- srctreeclone | 2 +- 5 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 Session03/Session03.sln create mode 100644 Session03/Session03Exercise02/Program.cs create mode 100644 Session03/Session03Exercise02/Session03Exercise02.csproj diff --git a/Session03/Session03.sln b/Session03/Session03.sln new file mode 100644 index 0000000..0145b8a --- /dev/null +++ b/Session03/Session03.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30330.147 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Session03Exercise02", "Session03Exercise02\Session03Exercise02.csproj", "{AC8EF63F-B225-4D1A-AB4E-0DED2349D8CD}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AC8EF63F-B225-4D1A-AB4E-0DED2349D8CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AC8EF63F-B225-4D1A-AB4E-0DED2349D8CD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AC8EF63F-B225-4D1A-AB4E-0DED2349D8CD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AC8EF63F-B225-4D1A-AB4E-0DED2349D8CD}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F9EA986A-D463-4C01-AAE3-D2F92EF01A3C} + EndGlobalSection +EndGlobal diff --git a/Session03/Session03Exercise02/Program.cs b/Session03/Session03Exercise02/Program.cs new file mode 100644 index 0000000..790a41e --- /dev/null +++ b/Session03/Session03Exercise02/Program.cs @@ -0,0 +1,22 @@ + +using System; + +namespace Session03Exercise02 +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Ange ett antal siffron, separat med kommatecken."); + var input = Console.ReadLine(); + + var inputArray = input.Split(',', StringSplitOptions.RemoveEmptyEntries);//new [] för FrameWork + foreach (var number in inputArray) + { + Console.WriteLine("Värdet är " + number); + } + + Console.ReadKey(); + } + } +} diff --git a/Session03/Session03Exercise02/Session03Exercise02.csproj b/Session03/Session03Exercise02/Session03Exercise02.csproj new file mode 100644 index 0000000..c73e0d1 --- /dev/null +++ b/Session03/Session03Exercise02/Session03Exercise02.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + diff --git a/Session2/Session02/Session02Exercise01/Program.cs b/Session2/Session02/Session02Exercise01/Program.cs index fddee64..c4359a3 100644 --- a/Session2/Session02/Session02Exercise01/Program.cs +++ b/Session2/Session02/Session02Exercise01/Program.cs @@ -14,9 +14,6 @@ static void Main(string[] args) Console.WriteLine("Integer is: " + integer); Console.WriteLine("value of my stringvalue: " + stringValue); - - - } } } diff --git a/srctreeclone b/srctreeclone index f0bd65b..2177031 160000 --- a/srctreeclone +++ b/srctreeclone @@ -1 +1 @@ -Subproject commit f0bd65ba05e036d62fcc364a4576ff7bad2b442d +Subproject commit 2177031157cda8cc592c01d82666a3813b51bcc4 From 01907aedf3f99aa0fb89075c1cc8035675b44312 Mon Sep 17 00:00:00 2001 From: TooOldForThisGit Date: Fri, 28 Aug 2020 13:09:23 +0200 Subject: [PATCH 12/14] Progress on number app --- Session03/Session03Exercise02/Program.cs | 42 ++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/Session03/Session03Exercise02/Program.cs b/Session03/Session03Exercise02/Program.cs index 790a41e..cfe0143 100644 --- a/Session03/Session03Exercise02/Program.cs +++ b/Session03/Session03Exercise02/Program.cs @@ -1,5 +1,8 @@  using System; +using System.Diagnostics; +using System.Globalization; +using System.Linq; namespace Session03Exercise02 { @@ -17,6 +20,45 @@ static void Main(string[] args) } Console.ReadKey(); + + Console.WriteLine("Ange ett antal siffror, separat med kommatecken."); + var inputNumber = Console.ReadLine(); + + var inputStringArray = inputNumber.Split(',', StringSplitOptions.RemoveEmptyEntries);//new [] för FrameWork + var numbers = new double[inputStringArray.Length]; + double middlevalue = 0; + + //while() + for (int i = 0; i < inputStringArray.Length; i++) + { + Console.WriteLine("Värdet är:".PadRight(14) + inputStringArray[i]); + try + { + double currentNumber = 0; + NumberStyles numberStyles = NumberStyles.Any | NumberStyles.Float; //bitwiseoperator + bool parsed = Double.TryParse(inputStringArray[i], numberStyles, CultureInfo.InvariantCulture, out currentNumber); + if (parsed) + { + numbers[i] = currentNumber; + middlevalue += currentNumber; + } + else continue; + + // Debug.Assert(i < numbers.Length - 1); + } + catch (Exception e) + { + Console.WriteLine(e); + throw; + } + + } + Console.WriteLine("-------------------------------------------\n"); + Console.WriteLine($"Högsta värdet: {numbers.Max()}");//Max value + Console.WriteLine($"Minsta värdet: {numbers.Min()}");//Min value + Console.WriteLine("Medelvärdet för arrayen är: " + string.Format($"{(middlevalue / numbers.Length):0.00}")); //Middle value + Console.ReadKey(); + } } } From ade67d758f2783455d5e30f4d7c20818d58293c4 Mon Sep 17 00:00:00 2001 From: TooOldForThisGit Date: Tue, 1 Sep 2020 12:00:20 +0200 Subject: [PATCH 13/14] Value input based on WordApp commit --- Session03/Session03Exercise02/Program.cs | 91 ++++++++++++++---------- 1 file changed, 53 insertions(+), 38 deletions(-) diff --git a/Session03/Session03Exercise02/Program.cs b/Session03/Session03Exercise02/Program.cs index cfe0143..0a2ac89 100644 --- a/Session03/Session03Exercise02/Program.cs +++ b/Session03/Session03Exercise02/Program.cs @@ -1,5 +1,6 @@ - + using System; +using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; @@ -8,57 +9,71 @@ namespace Session03Exercise02 { class Program { + static string line = "--------------------------------------------------------------"; + static void Main(string[] args) { - Console.WriteLine("Ange ett antal siffron, separat med kommatecken."); - var input = Console.ReadLine(); - - var inputArray = input.Split(',', StringSplitOptions.RemoveEmptyEntries);//new [] för FrameWork - foreach (var number in inputArray) + while (true)//Forever and ever n ever { - Console.WriteLine("Värdet är " + number); - } + Console.WriteLine("Ange ett antal siffror, separat med kommatecken."); + Console.WriteLine(line); - Console.ReadKey(); - - Console.WriteLine("Ange ett antal siffror, separat med kommatecken."); - var inputNumber = Console.ReadLine(); + var inputStringArray = Console.ReadLine().Split(',', StringSplitOptions.RemoveEmptyEntries);//new [] för FrameWork + List numbersArray = new List(); //A list so I dont need to sort unparsed values in for - var inputStringArray = inputNumber.Split(',', StringSplitOptions.RemoveEmptyEntries);//new [] för FrameWork - var numbers = new double[inputStringArray.Length]; - double middlevalue = 0; + double sum = 0; + double maxValue; + double minValue; - //while() - for (int i = 0; i < inputStringArray.Length; i++) - { - Console.WriteLine("Värdet är:".PadRight(14) + inputStringArray[i]); - try + int parseNumberCount = 0; //counter for divison with sum for middlevalue + + Console.WriteLine(line); + //Inputhandler + for (int i = 0; i < inputStringArray.Length; i++) { - double currentNumber = 0; - NumberStyles numberStyles = NumberStyles.Any | NumberStyles.Float; //bitwiseoperator - bool parsed = Double.TryParse(inputStringArray[i], numberStyles, CultureInfo.InvariantCulture, out currentNumber); - if (parsed) + var label = "Värdet är:"; + var paddedLabel = label.PadRight(14); + + try { - numbers[i] = currentNumber; - middlevalue += currentNumber; + double currentNumber; + NumberStyles numberStyles = NumberStyles.Any | NumberStyles.Float; //bitwiseoperator + bool parsed = double.TryParse(inputStringArray[i], numberStyles, CultureInfo.InvariantCulture, out currentNumber); + if (!parsed) //Jumps backs to the start of the iteration + continue; + else //Add elements to list and + { + numbersArray.Add(currentNumber); + sum += currentNumber; + ++parseNumberCount;//Perhaps exsessive in this stage + } + Console.WriteLine(paddedLabel + currentNumber); //Prints out inputvalue for user if correct + // Debug.Assert(i < numbers.Length - 1); //Remainer just for deeper studies in the subject } - else continue; - - // Debug.Assert(i < numbers.Length - 1); + catch (Exception ex) + { + Console.WriteLine(ex); + throw; + } + } - catch (Exception e) + //Assigning highest and smallest value if element in list is not zero + if (numbersArray.Count != 0) { - Console.WriteLine(e); - throw; + maxValue = numbersArray.Max(); + minValue = numbersArray.Min(); + + //Printing out evaluated values + Console.WriteLine(line); Console.WriteLine(); + Console.WriteLine($"Högsta värdet: {numbersArray.Max()}");//Max value + Console.WriteLine($"Minsta värdet: {numbersArray.Min()}");//Min value + Console.WriteLine("Medelvärdet för arrayen är: " + string.Format($"{(sum / parseNumberCount):0.00}")); //Middle value } + else Console.WriteLine("Här har det inte skrivits in nått värde alls. Försök igen!");//ERROR message + Console.WriteLine("\nTryck på valfri tangent för att köra programmet en gång till."); + Console.ReadKey(); } - Console.WriteLine("-------------------------------------------\n"); - Console.WriteLine($"Högsta värdet: {numbers.Max()}");//Max value - Console.WriteLine($"Minsta värdet: {numbers.Min()}");//Min value - Console.WriteLine("Medelvärdet för arrayen är: " + string.Format($"{(middlevalue / numbers.Length):0.00}")); //Middle value - Console.ReadKey(); - } } } From 32b1e016204ac762f82f517d9571ca6e9f404f47 Mon Sep 17 00:00:00 2001 From: TooOldForThisGit Date: Tue, 1 Sep 2020 15:04:44 +0200 Subject: [PATCH 14/14] Minor fix in inputvalue commit --- HolidayQuiz/HolidayQuiz.sln | 25 ++++++++++++++++++++++ HolidayQuiz/HolidayQuiz/HolidayQuiz.csproj | 8 +++++++ HolidayQuiz/HolidayQuiz/Program.cs | 12 +++++++++++ Session03/Session03Exercise02/Program.cs | 16 +++++++------- 4 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 HolidayQuiz/HolidayQuiz.sln create mode 100644 HolidayQuiz/HolidayQuiz/HolidayQuiz.csproj create mode 100644 HolidayQuiz/HolidayQuiz/Program.cs diff --git a/HolidayQuiz/HolidayQuiz.sln b/HolidayQuiz/HolidayQuiz.sln new file mode 100644 index 0000000..3e6cade --- /dev/null +++ b/HolidayQuiz/HolidayQuiz.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30330.147 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HolidayQuiz", "HolidayQuiz\HolidayQuiz.csproj", "{62C58643-5110-40F8-ACEA-6A77D2DD4F95}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {62C58643-5110-40F8-ACEA-6A77D2DD4F95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {62C58643-5110-40F8-ACEA-6A77D2DD4F95}.Debug|Any CPU.Build.0 = Debug|Any CPU + {62C58643-5110-40F8-ACEA-6A77D2DD4F95}.Release|Any CPU.ActiveCfg = Release|Any CPU + {62C58643-5110-40F8-ACEA-6A77D2DD4F95}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {AB8B192F-60E4-434F-A590-C946DE0A6AE5} + EndGlobalSection +EndGlobal diff --git a/HolidayQuiz/HolidayQuiz/HolidayQuiz.csproj b/HolidayQuiz/HolidayQuiz/HolidayQuiz.csproj new file mode 100644 index 0000000..c73e0d1 --- /dev/null +++ b/HolidayQuiz/HolidayQuiz/HolidayQuiz.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + diff --git a/HolidayQuiz/HolidayQuiz/Program.cs b/HolidayQuiz/HolidayQuiz/Program.cs new file mode 100644 index 0000000..15c5b5c --- /dev/null +++ b/HolidayQuiz/HolidayQuiz/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace HolidayQuiz +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} diff --git a/Session03/Session03Exercise02/Program.cs b/Session03/Session03Exercise02/Program.cs index 0a2ac89..28bf986 100644 --- a/Session03/Session03Exercise02/Program.cs +++ b/Session03/Session03Exercise02/Program.cs @@ -19,7 +19,7 @@ static void Main(string[] args) Console.WriteLine(line); var inputStringArray = Console.ReadLine().Split(',', StringSplitOptions.RemoveEmptyEntries);//new [] för FrameWork - List numbersArray = new List(); //A list so I dont need to sort unparsed values in for + List numbersList = new List(); //A list so I dont need to sort unparsed values in for double sum = 0; double maxValue; @@ -28,7 +28,7 @@ static void Main(string[] args) int parseNumberCount = 0; //counter for divison with sum for middlevalue Console.WriteLine(line); - //Inputhandler + //Input for (int i = 0; i < inputStringArray.Length; i++) { var label = "Värdet är:"; @@ -43,7 +43,7 @@ static void Main(string[] args) continue; else //Add elements to list and { - numbersArray.Add(currentNumber); + numbersList.Add(currentNumber); sum += currentNumber; ++parseNumberCount;//Perhaps exsessive in this stage } @@ -58,15 +58,15 @@ static void Main(string[] args) } //Assigning highest and smallest value if element in list is not zero - if (numbersArray.Count != 0) + if (numbersList.Count != 0) { - maxValue = numbersArray.Max(); - minValue = numbersArray.Min(); + maxValue = numbersList.Max(); + minValue = numbersList.Min(); //Printing out evaluated values Console.WriteLine(line); Console.WriteLine(); - Console.WriteLine($"Högsta värdet: {numbersArray.Max()}");//Max value - Console.WriteLine($"Minsta värdet: {numbersArray.Min()}");//Min value + Console.WriteLine($"Högsta värdet: {maxValue}");//Max value + Console.WriteLine($"Minsta värdet: {minValue}");//Min value Console.WriteLine("Medelvärdet för arrayen är: " + string.Format($"{(sum / parseNumberCount):0.00}")); //Middle value } else Console.WriteLine("Här har det inte skrivits in nått värde alls. Försök igen!");//ERROR message