diff --git a/Checkpoint1/.vscode/launch.json b/Checkpoint1/.vscode/launch.json new file mode 100644 index 00000000..bb71d335 --- /dev/null +++ b/Checkpoint1/.vscode/launch.json @@ -0,0 +1,28 @@ +{ + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/bin/Debug/netcoreapp2.0/Checkpoint1.dll", + "args": [], + "cwd": "${workspaceFolder}", + // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window + "console": "internalConsole", + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ,] +} \ No newline at end of file diff --git a/Checkpoint1/.vscode/tasks.json b/Checkpoint1/.vscode/tasks.json new file mode 100644 index 00000000..65947bdb --- /dev/null +++ b/Checkpoint1/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/Checkpoint1.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/Checkpoint1/Checkpoint1.cs b/Checkpoint1/Checkpoint1.cs index b7ed8611..3b8c7397 100644 --- a/Checkpoint1/Checkpoint1.cs +++ b/Checkpoint1/Checkpoint1.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; namespace Checkpoint1 { @@ -6,7 +7,84 @@ class Program { static void Main(string[] args) { - Console.WriteLine("Hello World!"); + //Program 1 + System.Console.WriteLine("Total amount of numbers between 1 and 100 that are divisible by 3 with no remainder:"); + Console.WriteLine(CountThrees()); + + //Program 2 + string InputStr; + int InputInt = 0, tempint = 0; + do + { + System.Console.WriteLine("Enter a number or type ok to exit"); + InputStr = Console.ReadLine(); + bool success = int.TryParse(InputStr, out tempint); + if (success == true) + { + InputInt += tempint; + } + if (success == false) + { + break; + } + Console.WriteLine($"Sum of the numbers is: {InputInt}"); + } + while (InputStr != "ok"); + + //Program 3 + int i, f = 1, num; + Console.WriteLine("\n\n"); + Console.WriteLine("Input a number:"); + num = Convert.ToInt32(Console.ReadLine()); + for (i = 1; i <= num; i++) + f = f * i; + + Console.WriteLine("{0}! = {1}", num, f); + + //Program 4 + System.Console.WriteLine("A random number is being picked between 1-10"); + System.Console.WriteLine("You have 4 tries to guess the number"); + int answer = 0; + int guess = 0; + Random number = new Random(); + answer = number.Next(1, 11); + for (int numrandom = 0; numrandom <= 4; numrandom++) + { + if (numrandom == 4) + { + System.Console.WriteLine("You lost"); + break; + } + System.Console.WriteLine("Enter guess"); + guess = Convert.ToInt32(Console.ReadLine()); + if (guess == answer) + { + System.Console.WriteLine("You Won!"); + break; + } + } + + //Program 5 + Console.WriteLine("Enter some numbers seperated by ", ""); + var numbers = Console.ReadLine(); + var splitNumber = numbers.Split(','); + var maxNumber = splitNumber.Max(); + Console.WriteLine("Highest is: " + maxNumber); + } + + static int CountThrees() + { + int count = 0; + + for (int i = 1; i <= 100; i++) + { + if (i % 3 == 0) + { + count++; + } + + } + return count; } } }