-
Notifications
You must be signed in to change notification settings - Fork 34
Number app #16
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
Tjocksmo
wants to merge
7
commits into
svenrog:master
Choose a base branch
from
Tjocksmo: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
Number app #16
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d401d40
Bara skrift
Tjocksmo 0711204
Ändrat
Tjocksmo 9bba491
Innehåller sträng
Tjocksmo 06749c0
Merge test and dev
Tjocksmo 6778b99
Did someting!
Tjocksmo 2d3de8e
Progress ongoing.
Tjocksmo ca3005f
Added an integer to get correct math in the division for midle value.
Tjocksmo 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,31 @@ | ||
using System; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace Excample02 | ||
{ | ||
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; | ||
|
||
else if (key.KeyChar == 'y') | ||
{ | ||
Console.WriteLine("\nEnter your name: "); | ||
var name = Console.ReadLine(); | ||
|
||
Console.WriteLine($"Hello, {name}"); | ||
} | ||
else | ||
{ | ||
Console.WriteLine("\nI don't understand?"); | ||
} | ||
Console.WriteLine("Press any key to exit program..."); | ||
Console.ReadKey(true); | ||
} | ||
} | ||
} |
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,43 @@ | ||
| ||
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", "{5781BFBB-1E01-47F7-A1DE-5BD53D78E140}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Session02exercise02", "Excample02\Session02exercise02.csproj", "{6B5DA0D0-23A1-47A2-B34F-A0A125A584FD}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Session02Excersise03", "Session02Excersise03\Session02Excersise03.csproj", "{4309C8FA-CF78-44EB-9535-36703D508250}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Session02Excersise04", "Session02Excersise04\Session02Excersise04.csproj", "{85B305B6-E306-4951-ADE5-01656F70DA96}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{5781BFBB-1E01-47F7-A1DE-5BD53D78E140}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{5781BFBB-1E01-47F7-A1DE-5BD53D78E140}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{5781BFBB-1E01-47F7-A1DE-5BD53D78E140}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{5781BFBB-1E01-47F7-A1DE-5BD53D78E140}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{6B5DA0D0-23A1-47A2-B34F-A0A125A584FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{6B5DA0D0-23A1-47A2-B34F-A0A125A584FD}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{6B5DA0D0-23A1-47A2-B34F-A0A125A584FD}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{6B5DA0D0-23A1-47A2-B34F-A0A125A584FD}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{4309C8FA-CF78-44EB-9535-36703D508250}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{4309C8FA-CF78-44EB-9535-36703D508250}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{4309C8FA-CF78-44EB-9535-36703D508250}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{4309C8FA-CF78-44EB-9535-36703D508250}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{85B305B6-E306-4951-ADE5-01656F70DA96}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{85B305B6-E306-4951-ADE5-01656F70DA96}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{85B305B6-E306-4951-ADE5-01656F70DA96}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{85B305B6-E306-4951-ADE5-01656F70DA96}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {B8AA34BE-8E82-4BCB-85BD-2689F1C50616} | ||
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,81 @@ | ||
using System; | ||
using System.Net.WebSockets; | ||
|
||
namespace Session02Excersise03 | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
//Binary operation | ||
var additionResult = 1 + 2; | ||
Console.WriteLine($"Addition result {additionResult}"); | ||
|
||
var incrementResult = ++additionResult; | ||
Console.WriteLine($"Increment result {incrementResult}"); | ||
|
||
var trueValue = true; | ||
|
||
var falseValue = false; | ||
|
||
// Bitwise operationer | ||
var andResult = 0b0010 & 0b0100; //0b0110; | ||
var orResult = 0b0001 | 0b0001; //0b0001; | ||
var xorResult = 0b0001 ^ 0b0001; //0b0000; | ||
|
||
Console.WriteLine($"and result {andResult}"); | ||
Console.WriteLine($"or result {orResult}"); | ||
Console.WriteLine($"xor result {xorResult}"); | ||
|
||
var modulResult = 3 % 2; | ||
Console.WriteLine($"modul result {modulResult}"); | ||
|
||
var highInteger = 1000; | ||
var integerDivisionResult = highInteger / 3; | ||
var doubleDivissionResult = highInteger / 3.0; | ||
|
||
Console.WriteLine($"integer division result {integerDivisionResult}"); | ||
Console.WriteLine($"double division result {doubleDivissionResult}"); | ||
|
||
//implicit värdekonvertering till double | ||
var forcedIntDivisionResult = (int)(highInteger / 3.0); | ||
Console.WriteLine($"forced int division result {forcedIntDivisionResult}"); | ||
|
||
var conversionResult = Convert.ToInt32(doubleDivissionResult); | ||
|
||
Console.WriteLine($"Conversion result {conversionResult}"); | ||
|
||
var midpointDivisionResult = 10.0 / 3.0; | ||
|
||
Console.WriteLine($"Midpoint division result {midpointDivisionResult}"); | ||
Console.WriteLine($"castToInt" + ((int)midpointDivisionResult).ToString()); | ||
Console.WriteLine($"ceiling " + Math.Ceiling(midpointDivisionResult)); | ||
Console.WriteLine($"floor " + Math.Floor(midpointDivisionResult)); | ||
Console.WriteLine($"ceiling " + Math.Round(midpointDivisionResult)); | ||
|
||
//T | ||
additionResult += 2; //Samma som (additionalResult = additionalResult + 2) | ||
additionResult -= 2; | ||
additionResult *= 2; | ||
additionResult /= 2; | ||
|
||
//Boelska jämförelseoperatorer | ||
var greaterThanResult = 5 > 3; | ||
var lessThanResult = 5 < 3; | ||
var greaterOrEqual = 5 >= 5; | ||
var lessOrEqual = 3 <= 5; | ||
|
||
Console.WriteLine($"greaterThanResult {greaterThanResult}"); | ||
Console.WriteLine($"lessThanResult {lessThanResult}"); | ||
Console.WriteLine($"greater or Equal {greaterOrEqual}"); | ||
Console.WriteLine($"less or equal {lessOrEqual}"); | ||
|
||
var andOperationsResult = true && false; | ||
var orOperationResult = false || true; | ||
|
||
Console.WriteLine($"And operations Result {andOperationsResult}"); | ||
Console.WriteLine($"Or operations Result {orOperationResult}"); | ||
Console.ReadKey(true); | ||
} | ||
} | ||
} |
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,40 @@ | ||
using System; | ||
|
||
namespace Session02Excersise04 | ||
{ | ||
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 tobak! "); | ||
//} | ||
|
||
//if (integer >= 40) | ||
//{ | ||
// Console.WriteLine("Men du är för gammal för att röka!"); | ||
//} | ||
|
||
Console.WriteLine("Ange en badtemperatur i grader C: "); | ||
|
||
var input = Console.ReadLine(); | ||
var integer = Convert.ToInt32(input); | ||
|
||
string waterLabel = integer >= 27 ? "Det går bra att bada" : "Det går inte att bada"; | ||
Console.WriteLine($"{waterLabel} i havet!"); | ||
|
||
Console.WriteLine("Tryck på valfri tangent för att avsluta..."); | ||
Console.ReadKey(true); | ||
} | ||
} | ||
} |
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,18 @@ | ||
using System; | ||
|
||
namespace Session02Exercise01 | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
Console.WriteLine("Hello world!"); | ||
var integer = 0; | ||
Console.WriteLine("integer is" + integer.ToString()); | ||
|
||
string stringValue = "My string is cool!"; | ||
|
||
Console.WriteLine($"The string value of stringValie is {stringValue}"); | ||
} | ||
} | ||
} |
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,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}") = "Session03Exersise01", "Session03Exersise01\Session03Exersise01.csproj", "{9C90BA88-D314-4C64-8D2C-BDE6CA882C1E}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{9C90BA88-D314-4C64-8D2C-BDE6CA882C1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{9C90BA88-D314-4C64-8D2C-BDE6CA882C1E}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{9C90BA88-D314-4C64-8D2C-BDE6CA882C1E}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{9C90BA88-D314-4C64-8D2C-BDE6CA882C1E}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {DAB41CAE-214D-40AB-BD39-8D5A82665136} | ||
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,92 @@ | ||
using System; | ||
using System.Globalization; | ||
using System.Linq; | ||
|
||
namespace Session03Exersise01 | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
double doubleMid = 0; | ||
double dblSum = 0; | ||
int intParsedOk = 0; | ||
|
||
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]; | ||
|
||
for (int i = 0; i < inputArray.Length; i++) | ||
{ | ||
bool parsed; | ||
|
||
try | ||
{ | ||
numberArray[i] = Convert.ToDouble(inputArray[i]); | ||
parsed = true; | ||
intParsedOk++; | ||
} | ||
|
||
catch (Exception) | ||
{ | ||
numberArray[i] = 0; | ||
parsed = false; | ||
} | ||
|
||
if (parsed == false) | ||
{ | ||
continue; | ||
} | ||
|
||
dblSum += numberArray[i].Value; | ||
} | ||
doubleMid = dblSum / intParsedOk; | ||
|
||
|
||
Console.WriteLine($"Min value is: {numberArray.Min()} Maxvalue is: {numberArray.Max()} Total value is: {dblSum} Midvalue is: {doubleMid :f2}"); | ||
|
||
Console.WriteLine("\nPress any key to quit program..."); | ||
Console.ReadKey(true); | ||
|
||
//for (int i = 0; i < inputArray.Length; i++) | ||
//{ | ||
// NumberStyles numberStyle = NumberStyles.Integer | NumberStyles.Float; //Bestämmer vilken typ man vill parsa till! | ||
// IFormatProvider formatProvider = new CultureInfo("sv-SE"); //CultureInfo.InvariantCulture; | ||
// IFormatProvider currentNulture = CultureInfo.CurrentCulture;*/ | ||
|
||
// bool parsed = double.TryParse(inputArray[i], out double parsedValue); | ||
|
||
|
||
|
||
//if (parsed == true) | ||
//{ | ||
// numberArray[i] = parsedValue; | ||
//} | ||
//else | ||
//{ | ||
// numberArray[i] = null; | ||
//} | ||
} | ||
|
||
//static double GetDoubleValue(string input) | ||
//{ | ||
// try | ||
// { | ||
// //numberArray[i] = Convert.ToDouble(inputArray[i]); | ||
// var result = int.Parse(input); | ||
// return result; | ||
// } | ||
// catch (FormatException ex) | ||
// { | ||
// return double.MinValue; | ||
|
||
// throw ex; | ||
// } | ||
// 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,8 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
</PropertyGroup> | ||
|
||
</Project> |
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.
Tur att jag slutade.
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.
Haha! Ja jag med. Snusar gör jag tyvärr.
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.
Gjorde jag med fram till för 3 år sedan. Dyrt och jobbigt att sluta.