From b018f49aabb68d5ee688ea6f114109370ada8c58 Mon Sep 17 00:00:00 2001 From: Andy Fogarasi Date: Sun, 7 Apr 2019 11:22:10 -0500 Subject: [PATCH 1/3] Completed week1-1 assignment --- HelloWorld/.vscode/launch.json | 28 +++++++++ HelloWorld/.vscode/tasks.json | 15 +++++ HelloWorld/HelloWorld.cs | 101 ++++++++++++++++++++++++++++++++- PigLatin/PigLatin.cs | 1 + 4 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 HelloWorld/.vscode/launch.json create mode 100644 HelloWorld/.vscode/tasks.json diff --git a/HelloWorld/.vscode/launch.json b/HelloWorld/.vscode/launch.json new file mode 100644 index 00000000..034b33c0 --- /dev/null +++ b/HelloWorld/.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/HelloWorld.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/HelloWorld/.vscode/tasks.json b/HelloWorld/.vscode/tasks.json new file mode 100644 index 00000000..7cf275a8 --- /dev/null +++ b/HelloWorld/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/HelloWorld.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/HelloWorld/HelloWorld.cs b/HelloWorld/HelloWorld.cs index 8168c805..a9d9867a 100644 --- a/HelloWorld/HelloWorld.cs +++ b/HelloWorld/HelloWorld.cs @@ -6,7 +6,104 @@ class Program { static void Main(string[] args) { - Console.WriteLine("Hello World!"); - } + +//Hello Wrorld Assignment + //Write a C# program that prints to screen "Hello my name is Andy" then + Console.WriteLine("Hello my name is Andy!"); + //Ask user for name "user name" + Console.WriteLine("What is your name?"); + //Get "user name" + string userName = Console.ReadLine(); + //Print to screen "Nice to meet you" "user name" + Console.WriteLine("Nice to meet you "+userName); + +//Day 1 Lesson + //Write a C# program that takes two numbers as input, adds them together, and displays the result of that operation + int number1 = 0; + int number2 = 0; + int total = 0; + + //note: the Parse method converts a string to a number - you define the number type (int, float, long, double, etc) + Console.WriteLine("Please enter a whole number greater than 0: "); + number1 = int.Parse(Console.ReadLine()); + + Console.WriteLine("Please enter another whole number greater than 0: "); + number2 = int.Parse(Console.ReadLine()); + + total = number1 + number2; + Console.WriteLine("Sum of two whole numbers, result = "+ total); + + //Write a C# program that converts yards to inches. + int yards = 0; + int inches = 32; + + Console.WriteLine("Enter a whole number of yards to convert: "); + yards = int.Parse(Console.ReadLine()); + + inches = yards * inches; + Console.WriteLine("Number of inches = "+ inches); + + //Create and define the variable people as true. + bool people = true; + + // Create and define the variable f as false. + bool f = false; + + // Create and define the variable num to be a decimal. + double num = 0; + + // Display the product of num multiplied by itself. + Console.WriteLine("Enter a whole number to be squared: "); + num = int.Parse(Console.ReadLine()); + + num = Math.Pow(num,2); + Console.WriteLine("Number squared = "+ num); + + // Create the following variables with your personal information: + // firstName + string firstName = "Andy"; + + // lastName + string lastName = "Fogarasi"; + + // age + int age = 55; + + // job + string job = "entrepreneur"; + + // favoriteBand + string favoriteBand = "Zac Brown"; + + // favoriteSportsTeam + string favoriteSportsTeam = "Hoonigan Racing"; + + // Experiment with Console.WriteLine(); to print out different pieces of your personal information. + Console.WriteLine("My name is "+ firstName + ' '+lastName); + Console.WriteLine("I am "+ age + " years old"); + Console.WriteLine("I am an "+ job); + Console.WriteLine("My favorite band is "+ favoriteBand); + Console.WriteLine("My favorite sports team is "+ favoriteSportsTeam); + + // Convert the variable num to an int. + num = (double) 6.89; + // Explicit cast double to int. + num = (int) num; + Console.WriteLine("Explict cast of double to int. Any decimals are truncated: "+ num); + + // Print to the console the sum, product, difference, and quotient of 100 and 10. + int num1 = 100; + int num2 = 10; + int sum = num1 + num2; + int prod = num1 * num2; + int dif = num1 - num2; + int quo = num1 / num2; + + Console.WriteLine("The sum, product, difference and quotient of 100 and 10 are:"); + Console.WriteLine("Sum: " + sum); + Console.WriteLine("Product: " + prod); + Console.WriteLine("Difference: " + dif); + Console.WriteLine("Quotient: " + quo); + } } } diff --git a/PigLatin/PigLatin.cs b/PigLatin/PigLatin.cs index 702647dd..ecee597e 100644 --- a/PigLatin/PigLatin.cs +++ b/PigLatin/PigLatin.cs @@ -9,6 +9,7 @@ public static void Main() // your code goes here // leave this command at the end so your program does not close automatically + Console.WriteLine("What is your name?"); Console.ReadLine(); } From d6bed818e886ccc36b0f2fe8a65632b885eab198 Mon Sep 17 00:00:00 2001 From: Andy Fogarasi Date: Sun, 7 Apr 2019 17:14:23 -0500 Subject: [PATCH 2/3] completed Pig Latin --- PigLatin/.vscode/launch.json | 28 +++++++++++++++++++ PigLatin/.vscode/tasks.json | 15 ++++++++++ PigLatin/PigLatin.cs | 54 ++++++++++++++++++++++++++++++------ 3 files changed, 88 insertions(+), 9 deletions(-) create mode 100644 PigLatin/.vscode/launch.json create mode 100644 PigLatin/.vscode/tasks.json diff --git a/PigLatin/.vscode/launch.json b/PigLatin/.vscode/launch.json new file mode 100644 index 00000000..dbee6e56 --- /dev/null +++ b/PigLatin/.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/PigLatin.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/PigLatin/.vscode/tasks.json b/PigLatin/.vscode/tasks.json new file mode 100644 index 00000000..a705ed07 --- /dev/null +++ b/PigLatin/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/PigLatin.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/PigLatin/PigLatin.cs b/PigLatin/PigLatin.cs index ecee597e..bef04be0 100644 --- a/PigLatin/PigLatin.cs +++ b/PigLatin/PigLatin.cs @@ -6,17 +6,53 @@ class Program { public static void Main() { - // your code goes here + // your code goes here - // leave this command at the end so your program does not close automatically - Console.WriteLine("What is your name?"); - Console.ReadLine(); + // Enter one word, translate it to Piglatin and print the translation to the screen + // Rules: + // 1) any letters before the first vowel get moved to the end of the word + // 2) if the updated word ends in a vowel add "yay" to the end + // 3) if the updated word ends in a consonant add "ay" to the end + // 4) Translator must pass the following tests: + // - elephant -> elephantay + // - fox -> oxfay + // - tsk -> tskay + // - are -> areyay + // - mine -> inemay + // - thing -> ingthay + + // Enter a word and assign it to a variable + Console.WriteLine("Please enter a word to translate to Pig Latin: "); + string englishWord = Console.ReadLine(); + + // Search word for the first vowel and identify its index + char[] vowels = { 'a', 'e', 'i', 'o', 'u' }; + + int letterIdx = englishWord.IndexOfAny(vowels); + // exception if there are no vowels + if (letterIdx < 0) { + letterIdx = 0; } - - public static string TranslateWord(string word) - { - // your code goes here - return word; + + // Assign beginning of new Pigword to a variable, assign letters before first vowel to a different variable, and joing them. + string pigWord = englishWord.Substring(letterIdx); + string firstHalf = englishWord.Substring(0,letterIdx); + pigWord = pigWord + firstHalf; + + // If last letter in pigWord assembly is a vowel add "yay". If not add "ay". Then Print. + char lastLetter = pigWord[pigWord.Length - 1]; + string last = char.ToString(lastLetter); + int lastIdx = last.IndexOfAny(vowels); + + // if pigWord ends in a consonant + if (lastIdx < 0) { + pigWord = pigWord + "ay"; + } + // if pigWord ends in a vowel + else { + pigWord = pigWord + "yay"; + } + Console.WriteLine(pigWord); } } } From 58a8e5764c63ca8032c4b06d478ebbfd6bc6e6ff Mon Sep 17 00:00:00 2001 From: Andy Fogarasi Date: Sun, 7 Apr 2019 17:33:27 -0500 Subject: [PATCH 3/3] 2nd try loading Pig Latin --- PigLatin/PigLatin.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/PigLatin/PigLatin.cs b/PigLatin/PigLatin.cs index bef04be0..f4b938ea 100644 --- a/PigLatin/PigLatin.cs +++ b/PigLatin/PigLatin.cs @@ -52,6 +52,7 @@ public static void Main() else { pigWord = pigWord + "yay"; } + Console.WriteLine(pigWord); } }