-
Notifications
You must be signed in to change notification settings - Fork 34
Numbers #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
emilmartinelle
wants to merge
9
commits into
svenrog:master
Choose a base branch
from
emilmartinelle:numbers
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Numbers #2
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e76432a
Initial commit - Session02
77374d5
revert
74d7b0d
revert
bf667dc
revert
d8d6d05
Session03 - Exercises01-02
185cdc1
exercise02
c7d891b
numbers
9201e56
numbers
26ae571
Number app progress
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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}") = "NumbersTest", "NumbersTest\NumbersTest.csproj", "{408EA78E-1721-4604-85CC-08B454FA2E3B}" | ||
| EndProject | ||
| Global | ||
| GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
| Debug|Any CPU = Debug|Any CPU | ||
| Release|Any CPU = Release|Any CPU | ||
| EndGlobalSection | ||
| GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
| {408EA78E-1721-4604-85CC-08B454FA2E3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
| {408EA78E-1721-4604-85CC-08B454FA2E3B}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
| {408EA78E-1721-4604-85CC-08B454FA2E3B}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
| {408EA78E-1721-4604-85CC-08B454FA2E3B}.Release|Any CPU.Build.0 = Release|Any CPU | ||
| EndGlobalSection | ||
| GlobalSection(SolutionProperties) = preSolution | ||
| HideSolutionNode = FALSE | ||
| EndGlobalSection | ||
| GlobalSection(ExtensibilityGlobals) = postSolution | ||
| SolutionGuid = {9E1D9868-8CBD-46CF-854B-B2788774905B} | ||
| EndGlobalSection | ||
| EndGlobal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>netcoreapp3.1</TargetFramework> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| namespace Session03Numbers | ||
| { | ||
| using System; | ||
| using System.Globalization; | ||
|
|
||
| namespace Session03Exercise02 | ||
| { | ||
| class Program | ||
| { | ||
| static void Main(string[] args) | ||
| { | ||
| Console.WriteLine("Ange ett antal siffror, separat med kommatecken"); | ||
|
|
||
| var input = Console.ReadLine(); | ||
|
|
||
| var inputArray = input.Split(",", StringSplitOptions.RemoveEmptyEntries); | ||
| double[] numberArray = new double[inputArray.Length]; | ||
|
|
||
| for (int i = 0; i < inputArray.Length; i++) | ||
| { | ||
| NumberStyles numberStyles=NumberStyles.Integer | ||
|
|
||
| try | ||
| { | ||
| numberArray[i] = Convert.ToDouble(inputArray[i]); | ||
| } | ||
|
|
||
| catch (Exception) | ||
| { | ||
| numberArray[i] = 0; | ||
| } | ||
|
|
||
| /*/ finally Körs alltid ovasett vad som händer med koden | ||
| * Måste vara i en loop /*/ | ||
| { | ||
|
|
||
| } | ||
| /*/throw new Exception("Provocerat fel") Är ett egenskapat fel/*/ | ||
|
|
||
| foreach (var number in numberArray) | ||
| { | ||
| Console.WriteLine("Värde: " + number.ToString()); | ||
| } | ||
| static double GetDoubleValue(string input) | ||
| { | ||
| try | ||
| { | ||
| var result = int.Parse(input); | ||
|
|
||
| return result; | ||
| } | ||
| catch (FormatException ex) when (ex.Message.Contains("Input string")) | ||
| { | ||
| return double.MinValue; | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| return 0; | ||
| } | ||
| } | ||
|
|
||
|
|
||
|
|
||
| } | ||
| } | ||
|
|
||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| | ||
| 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}") = "Session03Exercise01", "Session03Exercise01\Session03Exercise01.csproj", "{1DA37EB2-8B33-4F46-9531-0BF485D85D43}" | ||
| EndProject | ||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Session03Exercise02", "Session03Exercise02\Session03Exercise02.csproj", "{4EC32C31-2B0E-43AF-AF81-0AE8350D391A}" | ||
| EndProject | ||
| Global | ||
| GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
| Debug|Any CPU = Debug|Any CPU | ||
| Release|Any CPU = Release|Any CPU | ||
| EndGlobalSection | ||
| GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
| {1DA37EB2-8B33-4F46-9531-0BF485D85D43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
| {1DA37EB2-8B33-4F46-9531-0BF485D85D43}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
| {1DA37EB2-8B33-4F46-9531-0BF485D85D43}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
| {1DA37EB2-8B33-4F46-9531-0BF485D85D43}.Release|Any CPU.Build.0 = Release|Any CPU | ||
| {4EC32C31-2B0E-43AF-AF81-0AE8350D391A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
| {4EC32C31-2B0E-43AF-AF81-0AE8350D391A}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
| {4EC32C31-2B0E-43AF-AF81-0AE8350D391A}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
| {4EC32C31-2B0E-43AF-AF81-0AE8350D391A}.Release|Any CPU.Build.0 = Release|Any CPU | ||
| EndGlobalSection | ||
| GlobalSection(SolutionProperties) = preSolution | ||
| HideSolutionNode = FALSE | ||
| EndGlobalSection | ||
| GlobalSection(ExtensibilityGlobals) = postSolution | ||
| SolutionGuid = {C3302251-CC54-46F8-8F3E-6513ADE2B657} | ||
| EndGlobalSection | ||
| EndGlobal |
40 changes: 40 additions & 0 deletions
40
Ny mapp/Session03Exercise01/Session03Exercise01/Program.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| using System; | ||
|
|
||
| namespace Session03Exercise01 | ||
| { | ||
| class Program | ||
| { | ||
| static void Main(string[] args) | ||
| { | ||
| int[] integerValues = new [] { 1, 2, 3 }; | ||
| var integerValueName = nameof(integerValues); | ||
|
|
||
| for (var i = 0; i < integers.Length; i++) | ||
| { | ||
| var name = nameof(integers); | ||
| var value = integers[i]; | ||
|
|
||
| Console.WriteLine($"Index {i} i arrayen {nameof(integers)} har värdet: {integers[i]}"); | ||
| } | ||
| var doWhileIndex = 0; | ||
|
|
||
| do | ||
| { | ||
| var value = integerValues[doWhileIndex]; | ||
|
|
||
| Console.WriteLine($"Index{doWhileIndex} i arrayen {integerValueName} har värdet: {value}"); | ||
| doWhileIndex++; | ||
| } | ||
| while (doWhileIndex < integerValues.Length); | ||
|
|
||
| var whileIndex = 0; | ||
|
|
||
| while (whileIndex++ < integersValues < whileIndex) | ||
|
|
||
| Console.WriteLine($"While Index {whileIndex} i arrayen {integerValueName} har värdet: {value}"); | ||
|
|
||
| whileIndex++; | ||
|
|
||
| } | ||
| } | ||
| } |
8 changes: 8 additions & 0 deletions
8
Ny mapp/Session03Exercise01/Session03Exercise01/Session03Exercise01.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>netcoreapp3.1</TargetFramework> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> |
21 changes: 21 additions & 0 deletions
21
Ny mapp/Session03Exercise01/Session03Exercise02/Program.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| using System; | ||
|
|
||
| namespace Session03Exercise02 | ||
| { | ||
| class Program | ||
| { | ||
| static void Main(string[] args) | ||
| { | ||
| Console.WriteLine("Ange ett antal siffror, separat med kommatecken"); | ||
|
|
||
| var input = Console.ReadLine(); | ||
|
|
||
| var inputArray = input.Split(",", StringSplitOptions.RemoveEmptyEntries); | ||
|
|
||
| foreach (var number in inputArray) | ||
| { | ||
| Console.WriteLine("Värdet är " + number); | ||
| } | ||
| } | ||
| } | ||
| } |
8 changes: 8 additions & 0 deletions
8
Ny mapp/Session03Exercise01/Session03Exercise02/Session03Exercise02.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>netcoreapp3.1</TargetFramework> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> |
95 changes: 95 additions & 0 deletions
95
Session02/Session02Example01/Session02Example01/Program.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| using System; | ||
| using System.Xml.Schema; | ||
|
|
||
| namespace Session02Example01 | ||
| { | ||
| class Program | ||
| { | ||
| static void Main(string[] args) | ||
| { | ||
| // Binary operation | ||
| var additionResult = 1 + 2; | ||
|
|
||
| Console.WriteLine("additionalResult " + additionResult.ToString()); | ||
|
|
||
| var incrementResult = ++additionResult; | ||
|
|
||
| Console.WriteLine("incrementResult " + incrementResult.ToString()); | ||
|
|
||
| var trueValue = true; | ||
|
|
||
| var falseValue = false; | ||
|
|
||
| var andResult = trueValue & falseValue; // 0b0110 | ||
| var orResult = trueValue | falseValue; | ||
| var xorResult = trueValue ^ falseValue; | ||
|
|
||
| Console.WriteLine("andResult " + andResult); | ||
| Console.WriteLine("orResult " + orResult); | ||
| Console.WriteLine("xorResult " + xorResult); | ||
|
|
||
| var moduloResult = 7 % 5; | ||
|
|
||
| Console.WriteLine("moduloResult " + moduloResult); | ||
|
|
||
| var highInteger = 1000; | ||
| var IntegerDivisionResult = highInteger / 3; | ||
|
|
||
| // Implicit värdekonvertering till double | ||
| var doubleDivisionResult = highInteger / 3.0; | ||
|
|
||
| Console.WriteLine("integerDivisionResult " + IntegerDivisionResult); | ||
| Console.WriteLine("doubleDivisionResult " + doubleDivisionResult); | ||
|
|
||
| var castIntDivisionResult = (int)(highInteger / 3.0); | ||
|
|
||
| Console.WriteLine("castIntDivisionResults " + castIntDivisionResult); | ||
|
|
||
| var conversionResult = Convert.ToInt32(doubleDivisionResult); | ||
|
|
||
| Console.WriteLine("convertionResult " + conversionResult); | ||
|
|
||
| var midpointDivisionResult = 10.0 / 3.0; | ||
|
|
||
| Console.WriteLine("midpointDivisionResult " + midpointDivisionResult); | ||
| Console.WriteLine("castToInt " + ((int)midpointDivisionResult).ToString()); | ||
|
|
||
| Console.WriteLine("ceiling " +Math.Ceiling(midpointDivisionResult)); | ||
| Console.WriteLine("floor " + Math.Floor(midpointDivisionResult)); | ||
| Console.WriteLine("round " + Math.Round(midpointDivisionResult)); | ||
| // Med decimaler | ||
| Console.WriteLine("round " + Math.Round(midpointDivisionResult,3)); | ||
|
|
||
|
|
||
| additionResult += 2; | ||
| additionResult -= 2; | ||
| additionResult /= 2; | ||
| additionResult *= 2; | ||
|
|
||
| //^^ Smidigare sätt än det nedanför. Gör samma sak | ||
|
|
||
| additionResult = additionResult + 2; | ||
|
|
||
| var greaterResult = 5 > 3; | ||
| var lessThanResult = 5 < 3; | ||
| var greaterOrEqual = 5 >= 3; | ||
| var lessOrEqual = 5 <= 3; | ||
|
|
||
| Console.WriteLine("greaterResult " + greaterResult); | ||
| Console.WriteLine("lessThanResult " + lessThanResult); | ||
| Console.WriteLine("greaterOrEqual " + greaterOrEqual); | ||
| Console.WriteLine("lessOrEqual " + lessOrEqual); | ||
|
|
||
| var andOperationResult = true && false; | ||
| var orOperationalResult = false || true; | ||
|
|
||
| Console.WriteLine("andOperationalResult " + andOperationResult); | ||
| Console.WriteLine("orOperationalResult " + orOperationalResult); | ||
|
|
||
|
|
||
|
|
||
| Console.ReadKey(); | ||
|
|
||
| } | ||
| } | ||
| } |
29 changes: 29 additions & 0 deletions
29
Session02/Session02Example02/Session02Example02/Program.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| using System; | ||
|
|
||
| namespace Session02Example02 | ||
| { | ||
| class Program | ||
| { | ||
| static void Main(string[] args) | ||
| { | ||
| Console.WriteLine("Ange Ålder: "); | ||
|
|
||
| var input = Console.ReadLine(); | ||
| var integer = Convert.ToInt32(input); | ||
|
|
||
| if (integer >= 18) | ||
| { | ||
| Console.WriteLine("Du får köpa tobaksprodukter"); | ||
| } | ||
| else | ||
| { | ||
| Console.WriteLine("Du får inte köpa tobaksprodukter"); | ||
| } | ||
|
|
||
| if (integer >= 40) | ||
| { | ||
| Console.WriteLine("Du är även jättegammal"); | ||
| } | ||
| } | ||
| } | ||
| } |
8 changes: 8 additions & 0 deletions
8
Session02/Session02Example02/Session02Example02/Session02Example02.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>netcoreapp3.1</TargetFramework> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> |
35 changes: 35 additions & 0 deletions
35
Session02/Session02Example03/Session02Example03/Program.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| using System; | ||
|
|
||
| namespace Session02Example03 | ||
| { | ||
| class Program | ||
| { | ||
| static void Main(string[] args) | ||
| { | ||
| var input = Console.ReadLine(); | ||
| var integer = Convert.ToInt32(input); | ||
|
|
||
| string waterLabel = integer >= 27 ? "Går bra att bada" : "Går inte att bada"; | ||
|
|
||
| /*/if(integer >27) | ||
| { | ||
| waterLabel = "Går bra att bada"; | ||
| } | ||
| else | ||
| { | ||
| waterLabel = "Går inte bra att bada"; | ||
| } | ||
| /*/ | ||
|
|
||
| //Om det är dessa exakta värden inträffar | ||
| switch (integer) | ||
| { | ||
| case 1: waterLabel = "Går inte bra att bada alls"; break; | ||
| case 3-: waterLabel = "Det är 3 minusgrader"; break; | ||
| default: /*Här kan man göra något om inget träffar*/ break; | ||
| } | ||
| Console.WriteLine(waterLabel + " i havet"); | ||
|
|
||
| } | ||
| } | ||
| } |
8 changes: 8 additions & 0 deletions
8
Session02/Session02Example03/Session02Example03/Session02Example03.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>netcoreapp3.1</TargetFramework> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try... catch... finally kan man köra i vilken del av koden som helst.