Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions Checkpoint1/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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}"
}
,]
}
15 changes: 15 additions & 0 deletions Checkpoint1/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/Checkpoint1.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
80 changes: 79 additions & 1 deletion Checkpoint1/Checkpoint1.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,90 @@
using System;
using System.Linq;

namespace Checkpoint1
{
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;
}
}
}