From e64eab2a3df877cf27e1854ce161b9b10004d088 Mon Sep 17 00:00:00 2001 From: Forrest-Flowers Date: Mon, 29 Oct 2018 18:10:22 -0500 Subject: [PATCH 01/12] Bug fixing. 3/5 Finished. guess game throwing weird exception --- Checkpoint1/divideByThree/Checkpoint1.cs | 22 +++++++++ .../{ => divideByThree}/Checkpoint1.csproj | 0 Checkpoint1/factorials/Checkpoint1.cs | 21 ++++++++ Checkpoint1/factorials/Checkpoint1.csproj | 8 +++ Checkpoint1/guessTheNumber/Program.cs | 49 +++++++++++++++++++ .../guessTheNumber/guessTheNumber.csproj | 8 +++ Checkpoint1/maxArray/Checkpoint1.cs | 29 +++++++++++ Checkpoint1/maxArray/Checkpoint1.csproj | 8 +++ Checkpoint1/{ => numList}/Checkpoint1.cs | 0 Checkpoint1/numList/Checkpoint1.csproj | 8 +++ 10 files changed, 153 insertions(+) create mode 100644 Checkpoint1/divideByThree/Checkpoint1.cs rename Checkpoint1/{ => divideByThree}/Checkpoint1.csproj (100%) create mode 100644 Checkpoint1/factorials/Checkpoint1.cs create mode 100644 Checkpoint1/factorials/Checkpoint1.csproj create mode 100644 Checkpoint1/guessTheNumber/Program.cs create mode 100644 Checkpoint1/guessTheNumber/guessTheNumber.csproj create mode 100644 Checkpoint1/maxArray/Checkpoint1.cs create mode 100644 Checkpoint1/maxArray/Checkpoint1.csproj rename Checkpoint1/{ => numList}/Checkpoint1.cs (100%) create mode 100644 Checkpoint1/numList/Checkpoint1.csproj diff --git a/Checkpoint1/divideByThree/Checkpoint1.cs b/Checkpoint1/divideByThree/Checkpoint1.cs new file mode 100644 index 00000000..841bf63b --- /dev/null +++ b/Checkpoint1/divideByThree/Checkpoint1.cs @@ -0,0 +1,22 @@ +using System; + +namespace divideByThree +{ + class Program + { + static void Main(string[] args) + { + int divisibleByThree = 0; + + for (int i = 0; i <= 100; i++) + { + if (i % 3 == 0) + { + divisibleByThree++; + } + } + + Console.WriteLine("There are {0} numbers between 1 and 100 that are divisible by 3 with no remainder.", divisibleByThree); + } + } +} diff --git a/Checkpoint1/Checkpoint1.csproj b/Checkpoint1/divideByThree/Checkpoint1.csproj similarity index 100% rename from Checkpoint1/Checkpoint1.csproj rename to Checkpoint1/divideByThree/Checkpoint1.csproj diff --git a/Checkpoint1/factorials/Checkpoint1.cs b/Checkpoint1/factorials/Checkpoint1.cs new file mode 100644 index 00000000..229de774 --- /dev/null +++ b/Checkpoint1/factorials/Checkpoint1.cs @@ -0,0 +1,21 @@ +using System; + +namespace factorials +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Please enter a number:"); + int num = Convert.ToInt32(Console.ReadLine()); + int fact = num; + + for (int i = num - 1; i >= 1; i--) + { + fact = fact * i; + } + + Console.WriteLine("{0}! = {1}", num, fact); + } + } +} diff --git a/Checkpoint1/factorials/Checkpoint1.csproj b/Checkpoint1/factorials/Checkpoint1.csproj new file mode 100644 index 00000000..ce1697ae --- /dev/null +++ b/Checkpoint1/factorials/Checkpoint1.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.0 + + + diff --git a/Checkpoint1/guessTheNumber/Program.cs b/Checkpoint1/guessTheNumber/Program.cs new file mode 100644 index 00000000..6fb70fa8 --- /dev/null +++ b/Checkpoint1/guessTheNumber/Program.cs @@ -0,0 +1,49 @@ +using System; + +namespace guessTheNumber +{ + class Program + { + static void Main(string[] args) + { + Random rnd = new Random(); + int num = rnd.Next(1, 11); + int chances = 4; + int guess = playerGuess(); + + Console.WriteLine("--- The secret number is {0} ---", num); + Console.WriteLine("GUESS THE NUMBER:"); + + while (chances > 0) + { + if (guess == num) + { + Console.WriteLine("Congrats, You Win!"); + return; + } + else if (guess != num) + { + chances--; + Console.WriteLine("Wrong, you have {0} chance(s) left.", chances); + + if (chances == 0) + { + Console.WriteLine("You've run out of guesses, You lost!"); + return; + } + else + { + playerGuess(); + } + } + + } + } + + public static int playerGuess() + { + int num1 = Convert.ToInt32(Console.ReadLine()); + return num1; + } + } +} \ No newline at end of file diff --git a/Checkpoint1/guessTheNumber/guessTheNumber.csproj b/Checkpoint1/guessTheNumber/guessTheNumber.csproj new file mode 100644 index 00000000..23df6047 --- /dev/null +++ b/Checkpoint1/guessTheNumber/guessTheNumber.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.1 + + + diff --git a/Checkpoint1/maxArray/Checkpoint1.cs b/Checkpoint1/maxArray/Checkpoint1.cs new file mode 100644 index 00000000..84ee9de8 --- /dev/null +++ b/Checkpoint1/maxArray/Checkpoint1.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; + +namespace maxArray +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Please enter a series of numbers, seperated by a comma:"); + int input = userInput(); + List list = new List { }; + + list.Add(input); + + foreach(int item in list) + { + Console.WriteLine(); + } + + } + + public static int userInput() + { + int input = Convert.ToInt32(Console.ReadLine()); + return input; + } + } +} diff --git a/Checkpoint1/maxArray/Checkpoint1.csproj b/Checkpoint1/maxArray/Checkpoint1.csproj new file mode 100644 index 00000000..ce1697ae --- /dev/null +++ b/Checkpoint1/maxArray/Checkpoint1.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.0 + + + diff --git a/Checkpoint1/Checkpoint1.cs b/Checkpoint1/numList/Checkpoint1.cs similarity index 100% rename from Checkpoint1/Checkpoint1.cs rename to Checkpoint1/numList/Checkpoint1.cs diff --git a/Checkpoint1/numList/Checkpoint1.csproj b/Checkpoint1/numList/Checkpoint1.csproj new file mode 100644 index 00000000..ce1697ae --- /dev/null +++ b/Checkpoint1/numList/Checkpoint1.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.0 + + + From 51df107342b67892c6902d54bf9f6d136411274a Mon Sep 17 00:00:00 2001 From: Forrest-Flowers Date: Mon, 29 Oct 2018 18:31:16 -0500 Subject: [PATCH 02/12] 4/5 done. Fixed guessNumber bug --- Checkpoint1/factorials/Checkpoint1.cs | 2 ++ Checkpoint1/guessTheNumber/Program.cs | 10 +++------- Checkpoint1/maxArray/Checkpoint1.cs | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Checkpoint1/factorials/Checkpoint1.cs b/Checkpoint1/factorials/Checkpoint1.cs index 229de774..3da3e0d9 100644 --- a/Checkpoint1/factorials/Checkpoint1.cs +++ b/Checkpoint1/factorials/Checkpoint1.cs @@ -6,10 +6,12 @@ class Program { static void Main(string[] args) { + //Get User Input. Console.WriteLine("Please enter a number:"); int num = Convert.ToInt32(Console.ReadLine()); int fact = num; + //int i, num and fact. Start i at 1 less than input and go down to 1 then multiply those numbers together to find fact. for (int i = num - 1; i >= 1; i--) { fact = fact * i; diff --git a/Checkpoint1/guessTheNumber/Program.cs b/Checkpoint1/guessTheNumber/Program.cs index 6fb70fa8..e9636475 100644 --- a/Checkpoint1/guessTheNumber/Program.cs +++ b/Checkpoint1/guessTheNumber/Program.cs @@ -9,13 +9,12 @@ static void Main(string[] args) Random rnd = new Random(); int num = rnd.Next(1, 11); int chances = 4; - int guess = playerGuess(); - Console.WriteLine("--- The secret number is {0} ---", num); Console.WriteLine("GUESS THE NUMBER:"); - while (chances > 0) + while (chances >= 0) { + int guess = playerGuess(); if (guess == num) { Console.WriteLine("Congrats, You Win!"); @@ -31,10 +30,7 @@ static void Main(string[] args) Console.WriteLine("You've run out of guesses, You lost!"); return; } - else - { - playerGuess(); - } + } } diff --git a/Checkpoint1/maxArray/Checkpoint1.cs b/Checkpoint1/maxArray/Checkpoint1.cs index 84ee9de8..209bcc8a 100644 --- a/Checkpoint1/maxArray/Checkpoint1.cs +++ b/Checkpoint1/maxArray/Checkpoint1.cs @@ -13,7 +13,7 @@ static void Main(string[] args) list.Add(input); - foreach(int item in list) + foreach (int item in list) { Console.WriteLine(); } From 4d6edcd7f9e2a3acb7c52c427f0ab149dbffaa66 Mon Sep 17 00:00:00 2001 From: Forrest-Flowers Date: Mon, 5 Nov 2018 18:12:30 -0600 Subject: [PATCH 03/12] .NET bug. Not creating bin --- .../{Checkpoint1.cs => Program.cs} | 3 +- .../divideByThree.csproj} | 2 +- Checkpoint1/factorials/Checkpoint1.csproj | 8 ---- .../factorials/{Checkpoint1.cs => Program.cs} | 0 .../factorials.csproj} | 2 +- Checkpoint1/guessTheNumber/Program.cs | 37 +------------------ Checkpoint1/maxArray/Checkpoint1.cs | 29 --------------- Checkpoint1/numList/Checkpoint1.cs | 12 ------ Checkpoint1/numList/Checkpoint1.csproj | 8 ---- 9 files changed, 5 insertions(+), 96 deletions(-) rename Checkpoint1/divideByThree/{Checkpoint1.cs => Program.cs} (83%) rename Checkpoint1/{maxArray/Checkpoint1.csproj => divideByThree/divideByThree.csproj} (68%) delete mode 100644 Checkpoint1/factorials/Checkpoint1.csproj rename Checkpoint1/factorials/{Checkpoint1.cs => Program.cs} (100%) rename Checkpoint1/{divideByThree/Checkpoint1.csproj => factorials/factorials.csproj} (68%) delete mode 100644 Checkpoint1/maxArray/Checkpoint1.cs delete mode 100644 Checkpoint1/numList/Checkpoint1.cs delete mode 100644 Checkpoint1/numList/Checkpoint1.csproj diff --git a/Checkpoint1/divideByThree/Checkpoint1.cs b/Checkpoint1/divideByThree/Program.cs similarity index 83% rename from Checkpoint1/divideByThree/Checkpoint1.cs rename to Checkpoint1/divideByThree/Program.cs index 841bf63b..de786213 100644 --- a/Checkpoint1/divideByThree/Checkpoint1.cs +++ b/Checkpoint1/divideByThree/Program.cs @@ -15,8 +15,7 @@ static void Main(string[] args) divisibleByThree++; } } - - Console.WriteLine("There are {0} numbers between 1 and 100 that are divisible by 3 with no remainder.", divisibleByThree); + Console.WriteLine("There are {0} numbers between 1 and 100 that are evenly divisible by 3", divisibleByThree); } } } diff --git a/Checkpoint1/maxArray/Checkpoint1.csproj b/Checkpoint1/divideByThree/divideByThree.csproj similarity index 68% rename from Checkpoint1/maxArray/Checkpoint1.csproj rename to Checkpoint1/divideByThree/divideByThree.csproj index ce1697ae..23df6047 100644 --- a/Checkpoint1/maxArray/Checkpoint1.csproj +++ b/Checkpoint1/divideByThree/divideByThree.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp2.0 + netcoreapp2.1 diff --git a/Checkpoint1/factorials/Checkpoint1.csproj b/Checkpoint1/factorials/Checkpoint1.csproj deleted file mode 100644 index ce1697ae..00000000 --- a/Checkpoint1/factorials/Checkpoint1.csproj +++ /dev/null @@ -1,8 +0,0 @@ - - - - Exe - netcoreapp2.0 - - - diff --git a/Checkpoint1/factorials/Checkpoint1.cs b/Checkpoint1/factorials/Program.cs similarity index 100% rename from Checkpoint1/factorials/Checkpoint1.cs rename to Checkpoint1/factorials/Program.cs diff --git a/Checkpoint1/divideByThree/Checkpoint1.csproj b/Checkpoint1/factorials/factorials.csproj similarity index 68% rename from Checkpoint1/divideByThree/Checkpoint1.csproj rename to Checkpoint1/factorials/factorials.csproj index ce1697ae..23df6047 100644 --- a/Checkpoint1/divideByThree/Checkpoint1.csproj +++ b/Checkpoint1/factorials/factorials.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp2.0 + netcoreapp2.1 diff --git a/Checkpoint1/guessTheNumber/Program.cs b/Checkpoint1/guessTheNumber/Program.cs index e9636475..f4587989 100644 --- a/Checkpoint1/guessTheNumber/Program.cs +++ b/Checkpoint1/guessTheNumber/Program.cs @@ -6,40 +6,7 @@ class Program { static void Main(string[] args) { - Random rnd = new Random(); - int num = rnd.Next(1, 11); - int chances = 4; - Console.WriteLine("--- The secret number is {0} ---", num); - Console.WriteLine("GUESS THE NUMBER:"); - - while (chances >= 0) - { - int guess = playerGuess(); - if (guess == num) - { - Console.WriteLine("Congrats, You Win!"); - return; - } - else if (guess != num) - { - chances--; - Console.WriteLine("Wrong, you have {0} chance(s) left.", chances); - - if (chances == 0) - { - Console.WriteLine("You've run out of guesses, You lost!"); - return; - } - - } - - } - } - - public static int playerGuess() - { - int num1 = Convert.ToInt32(Console.ReadLine()); - return num1; + Console.WriteLine("Hello World!"); } } -} \ No newline at end of file +} diff --git a/Checkpoint1/maxArray/Checkpoint1.cs b/Checkpoint1/maxArray/Checkpoint1.cs deleted file mode 100644 index 209bcc8a..00000000 --- a/Checkpoint1/maxArray/Checkpoint1.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace maxArray -{ - class Program - { - static void Main(string[] args) - { - Console.WriteLine("Please enter a series of numbers, seperated by a comma:"); - int input = userInput(); - List list = new List { }; - - list.Add(input); - - foreach (int item in list) - { - Console.WriteLine(); - } - - } - - public static int userInput() - { - int input = Convert.ToInt32(Console.ReadLine()); - return input; - } - } -} diff --git a/Checkpoint1/numList/Checkpoint1.cs b/Checkpoint1/numList/Checkpoint1.cs deleted file mode 100644 index b7ed8611..00000000 --- a/Checkpoint1/numList/Checkpoint1.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace Checkpoint1 -{ - class Program - { - static void Main(string[] args) - { - Console.WriteLine("Hello World!"); - } - } -} diff --git a/Checkpoint1/numList/Checkpoint1.csproj b/Checkpoint1/numList/Checkpoint1.csproj deleted file mode 100644 index ce1697ae..00000000 --- a/Checkpoint1/numList/Checkpoint1.csproj +++ /dev/null @@ -1,8 +0,0 @@ - - - - Exe - netcoreapp2.0 - - - From 5999cf11a46a180dac2069f1035db7fb1e0efb2f Mon Sep 17 00:00:00 2001 From: Forrest-Flowers Date: Mon, 5 Nov 2018 18:31:22 -0600 Subject: [PATCH 04/12] Adding everything into one project --- ...ivideByThree.csproj => Checkpoint1.csproj} | 0 Checkpoint1/Program.cs | 43 +++++++++++++++++++ Checkpoint1/divideByThree/Program.cs | 21 --------- Checkpoint1/factorials/Program.cs | 23 ---------- Checkpoint1/factorials/factorials.csproj | 8 ---- Checkpoint1/guessTheNumber/Program.cs | 12 ------ .../guessTheNumber/guessTheNumber.csproj | 8 ---- 7 files changed, 43 insertions(+), 72 deletions(-) rename Checkpoint1/{divideByThree/divideByThree.csproj => Checkpoint1.csproj} (100%) create mode 100644 Checkpoint1/Program.cs delete mode 100644 Checkpoint1/divideByThree/Program.cs delete mode 100644 Checkpoint1/factorials/Program.cs delete mode 100644 Checkpoint1/factorials/factorials.csproj delete mode 100644 Checkpoint1/guessTheNumber/Program.cs delete mode 100644 Checkpoint1/guessTheNumber/guessTheNumber.csproj diff --git a/Checkpoint1/divideByThree/divideByThree.csproj b/Checkpoint1/Checkpoint1.csproj similarity index 100% rename from Checkpoint1/divideByThree/divideByThree.csproj rename to Checkpoint1/Checkpoint1.csproj diff --git a/Checkpoint1/Program.cs b/Checkpoint1/Program.cs new file mode 100644 index 00000000..0e475d7d --- /dev/null +++ b/Checkpoint1/Program.cs @@ -0,0 +1,43 @@ +using System; + +namespace Checkpoint1 +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("There are {0} numbers between 1 and 100 that are evenly divisible by 3", divideByThree()); + Console.WriteLine("----------------------------------------------------------------------"); + + Console.WriteLine("Enter a number you want the factorial of:"); + int num = Convert.ToInt32(Console.ReadLine()); + Console.WriteLine("{0} != {1}", num, factorial()); + } + + public static int divideByThree() + { + int divisibleByThree = 0; + + for (int i = 0; i <= 100; i++) + { + if (i % 3 == 0) + { + divisibleByThree++; + } + } + return divisibleByThree; + } + + public static int factorial(int num) + { + int fact = num; + + //int i, num and fact. Start i at 1 less than input and go down to 1 then multiply those numbers together to find fact. + for (int i = num - 1; i >= 1; i--) + { + fact = fact * i; + } + return fact; + } + } +} diff --git a/Checkpoint1/divideByThree/Program.cs b/Checkpoint1/divideByThree/Program.cs deleted file mode 100644 index de786213..00000000 --- a/Checkpoint1/divideByThree/Program.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; - -namespace divideByThree -{ - class Program - { - static void Main(string[] args) - { - int divisibleByThree = 0; - - for (int i = 0; i <= 100; i++) - { - if (i % 3 == 0) - { - divisibleByThree++; - } - } - Console.WriteLine("There are {0} numbers between 1 and 100 that are evenly divisible by 3", divisibleByThree); - } - } -} diff --git a/Checkpoint1/factorials/Program.cs b/Checkpoint1/factorials/Program.cs deleted file mode 100644 index 3da3e0d9..00000000 --- a/Checkpoint1/factorials/Program.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; - -namespace factorials -{ - class Program - { - static void Main(string[] args) - { - //Get User Input. - Console.WriteLine("Please enter a number:"); - int num = Convert.ToInt32(Console.ReadLine()); - int fact = num; - - //int i, num and fact. Start i at 1 less than input and go down to 1 then multiply those numbers together to find fact. - for (int i = num - 1; i >= 1; i--) - { - fact = fact * i; - } - - Console.WriteLine("{0}! = {1}", num, fact); - } - } -} diff --git a/Checkpoint1/factorials/factorials.csproj b/Checkpoint1/factorials/factorials.csproj deleted file mode 100644 index 23df6047..00000000 --- a/Checkpoint1/factorials/factorials.csproj +++ /dev/null @@ -1,8 +0,0 @@ - - - - Exe - netcoreapp2.1 - - - diff --git a/Checkpoint1/guessTheNumber/Program.cs b/Checkpoint1/guessTheNumber/Program.cs deleted file mode 100644 index f4587989..00000000 --- a/Checkpoint1/guessTheNumber/Program.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace guessTheNumber -{ - class Program - { - static void Main(string[] args) - { - Console.WriteLine("Hello World!"); - } - } -} diff --git a/Checkpoint1/guessTheNumber/guessTheNumber.csproj b/Checkpoint1/guessTheNumber/guessTheNumber.csproj deleted file mode 100644 index 23df6047..00000000 --- a/Checkpoint1/guessTheNumber/guessTheNumber.csproj +++ /dev/null @@ -1,8 +0,0 @@ - - - - Exe - netcoreapp2.1 - - - From 1ba355ee77c376fbae64f1d6e5bb7d457ef12690 Mon Sep 17 00:00:00 2001 From: Forrest-Flowers Date: Mon, 5 Nov 2018 18:47:55 -0600 Subject: [PATCH 05/12] Bug on factorial --- Checkpoint1/Program.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Checkpoint1/Program.cs b/Checkpoint1/Program.cs index 0e475d7d..cec90773 100644 --- a/Checkpoint1/Program.cs +++ b/Checkpoint1/Program.cs @@ -11,7 +11,8 @@ static void Main(string[] args) Console.WriteLine("Enter a number you want the factorial of:"); int num = Convert.ToInt32(Console.ReadLine()); - Console.WriteLine("{0} != {1}", num, factorial()); + int fact = factorial(); + Console.WriteLine("{0} != {1}", num, fact); } public static int divideByThree() From 221a3dc3b9599b1475c19a2dca7d32777ae1463c Mon Sep 17 00:00:00 2001 From: Forrest-Flowers Date: Wed, 7 Nov 2018 18:49:23 -0600 Subject: [PATCH 06/12] Bigfixing adding project --- Checkpoint1/Program.cs | 99 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 87 insertions(+), 12 deletions(-) diff --git a/Checkpoint1/Program.cs b/Checkpoint1/Program.cs index cec90773..4487a31e 100644 --- a/Checkpoint1/Program.cs +++ b/Checkpoint1/Program.cs @@ -10,11 +10,55 @@ static void Main(string[] args) Console.WriteLine("----------------------------------------------------------------------"); Console.WriteLine("Enter a number you want the factorial of:"); - int num = Convert.ToInt32(Console.ReadLine()); - int fact = factorial(); - Console.WriteLine("{0} != {1}", num, fact); - } + Console.WriteLine(factorial()); + Console.WriteLine("------------------------------------------------------------------------"); + + int secretNum = numGen(); + int chances = 4; + + Console.WriteLine("--- The secret number is {0} ---", secretNum); + Console.WriteLine("GUESS THE NUMBER:"); + + int guess = playerGuess(); + while (chances >= 0) + { + + if (guess != secretNum) + { + chances--; + Console.WriteLine("Wrong, you have {0} chance(s) left.", chances); + playerGuess(); + } + else if (guess == secretNum) + { + Console.WriteLine("Congrats, You Win!"); + break; + } + + if (chances == 0) + { + Console.WriteLine("You've run out of guesses, You lost!"); + break; + } + + } + Console.WriteLine("----------------------------------------------------------------------------"); + + Console.WriteLine("Please enter a number. Enter 'OK' to add all previously entered numbers."); + string userInput = AddInput(); + int sum = 0; + if (userInput != "Ok" || userInput != "ok" || userInput != "OK" || userInput != "oK") + { + sum = Convert.ToInt32(userInput) + sum; + AddInput(); + } + else + { + Console.WriteLine(sum); + } + } + //Divide By Three project (Number 1 on list): public static int divideByThree() { int divisibleByThree = 0; @@ -28,17 +72,48 @@ public static int divideByThree() } return divisibleByThree; } - - public static int factorial(int num) + //Factorials project (Number 3 on list): + public static string factorial() { + int num = Convert.ToInt32(Console.ReadLine()); int fact = num; - //int i, num and fact. Start i at 1 less than input and go down to 1 then multiply those numbers together to find fact. - for (int i = num - 1; i >= 1; i--) - { - fact = fact * i; - } - return fact; + //int i, num and fact. Start i at 1 less than input and go down to 1 then multiply those numbers together to find fact. + for (int i = num - 1; i >= 1; i--) + { + fact = fact * i; + } + + string equation = $"{num} != {fact}"; + + return equation; + } + + public static int numGen() + { + Random rnd = new Random(); + int num = rnd.Next(1, 11); + return num; + } + + + public static int playerGuess() + { + int num1 = Convert.ToInt32(Console.ReadLine()); + return num1; + } + //Add Numbers Project (Number 2 on List.): + public static string AddInput() + { + string userInput = Console.ReadLine(); + return userInput; } + + } + + + } + + From 4317594f6f74e146f49262751b7dc58271e49e77 Mon Sep 17 00:00:00 2001 From: Forrest-Flowers Date: Mon, 12 Nov 2018 18:24:26 -0600 Subject: [PATCH 07/12] Bug on adding method. Endless loop --- Checkpoint1/Program.cs | 84 +++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 43 deletions(-) diff --git a/Checkpoint1/Program.cs b/Checkpoint1/Program.cs index 4487a31e..4885176f 100644 --- a/Checkpoint1/Program.cs +++ b/Checkpoint1/Program.cs @@ -6,58 +6,56 @@ class Program { static void Main(string[] args) { - Console.WriteLine("There are {0} numbers between 1 and 100 that are evenly divisible by 3", divideByThree()); - Console.WriteLine("----------------------------------------------------------------------"); + // Console.WriteLine("There are {0} numbers between 1 and 100 that are evenly divisible by 3", divideByThree()); + // Console.WriteLine("----------------------------------------------------------------------"); + + // Console.WriteLine("Enter a number you want the factorial of:"); + // Console.WriteLine(factorial()); + // Console.WriteLine("------------------------------------------------------------------------"); + + // int secretNum = numGen(); + // int chances = 4; + + // Console.WriteLine("--- The secret number is {0} ---", secretNum); + // Console.WriteLine("GUESS THE NUMBER:"); + + // int guess = playerGuess(); + // while (chances > 0) + // { + // if (guess == secretNum) + // { + // Console.WriteLine("Congrats, You Win!"); + // break; + // } + + // else if (guess != secretNum) + // { + // chances--; + // Console.WriteLine("Wrong, you have {0} chance(s) left.", chances); + // playerGuess(); + // } + // if (chances == 0) + // { + // Console.WriteLine("You've run out of tries. Try again."); + // break; + // } + + // } + // Console.WriteLine("----------------------------------------------------------------------------"); - Console.WriteLine("Enter a number you want the factorial of:"); - Console.WriteLine(factorial()); - Console.WriteLine("------------------------------------------------------------------------"); - - int secretNum = numGen(); - int chances = 4; - - Console.WriteLine("--- The secret number is {0} ---", secretNum); - Console.WriteLine("GUESS THE NUMBER:"); - - int guess = playerGuess(); - while (chances >= 0) - { - - if (guess != secretNum) - { - chances--; - Console.WriteLine("Wrong, you have {0} chance(s) left.", chances); - playerGuess(); - } - else if (guess == secretNum) - { - Console.WriteLine("Congrats, You Win!"); - break; - } - - - if (chances == 0) - { - Console.WriteLine("You've run out of guesses, You lost!"); - break; - } - - } - Console.WriteLine("----------------------------------------------------------------------------"); Console.WriteLine("Please enter a number. Enter 'OK' to add all previously entered numbers."); string userInput = AddInput(); int sum = 0; - if (userInput != "Ok" || userInput != "ok" || userInput != "OK" || userInput != "oK") + while (userInput != "ok") { sum = Convert.ToInt32(userInput) + sum; AddInput(); + Console.WriteLine("---{0}---", userInput); } - else - { - Console.WriteLine(sum); - } + Console.WriteLine(sum); } + //Divide By Three project (Number 1 on list): public static int divideByThree() { @@ -105,7 +103,7 @@ public static int playerGuess() //Add Numbers Project (Number 2 on List.): public static string AddInput() { - string userInput = Console.ReadLine(); + string userInput = Console.ReadLine().ToLower(); return userInput; } From 3792b9959997f7cd6c3ab8bcce421b419c2d6a65 Mon Sep 17 00:00:00 2001 From: Forrest-Flowers Date: Wed, 14 Nov 2018 18:30:58 -0600 Subject: [PATCH 08/12] Almost done, 50% done with final project. --- Checkpoint1/Program.cs | 48 +++++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/Checkpoint1/Program.cs b/Checkpoint1/Program.cs index 4885176f..321aafc6 100644 --- a/Checkpoint1/Program.cs +++ b/Checkpoint1/Program.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; namespace Checkpoint1 { @@ -44,16 +45,30 @@ static void Main(string[] args) // Console.WriteLine("----------------------------------------------------------------------------"); - Console.WriteLine("Please enter a number. Enter 'OK' to add all previously entered numbers."); - string userInput = AddInput(); - int sum = 0; - while (userInput != "ok") - { - sum = Convert.ToInt32(userInput) + sum; - AddInput(); - Console.WriteLine("---{0}---", userInput); - } - Console.WriteLine(sum); + // Console.WriteLine("Please enter a number. Enter 'OK' to add all previously entered numbers."); + // string userInput = AddInput(); + // int sum = 0; + // while (userInput != "ok") + // { + // sum = Convert.ToInt32(userInput) + sum; + + // userInput; + + // } + // Console.WriteLine(sum); + // Console.WriteLine("----------------------------------------------------------------------------------------"); + + + Console.WriteLine("Enter in 5 numbers separated with a comma."); + string input = + + + + + + + findMaxInArray(); + } //Divide By Three project (Number 1 on list): @@ -107,6 +122,19 @@ public static string AddInput() return userInput; } + // Max Array Project (Number 5 on List.): + + public static string intialInput() + { + string input = Console.ReadLine(); + return input; + } + + public static int findMaxInArray() + { + + } + } From f4484d410da4985db131d3ad16a4db1b8ec97389 Mon Sep 17 00:00:00 2001 From: Forrest-Flowers Date: Wed, 28 Nov 2018 18:33:10 -0600 Subject: [PATCH 09/12] Could not get #5. Turning in anyway --- Checkpoint1/Program.cs | 135 ++++++++++++++++++++++++----------------- 1 file changed, 78 insertions(+), 57 deletions(-) diff --git a/Checkpoint1/Program.cs b/Checkpoint1/Program.cs index 321aafc6..5ad51a8c 100644 --- a/Checkpoint1/Program.cs +++ b/Checkpoint1/Program.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; namespace Checkpoint1 { @@ -7,67 +8,85 @@ class Program { static void Main(string[] args) { - // Console.WriteLine("There are {0} numbers between 1 and 100 that are evenly divisible by 3", divideByThree()); - // Console.WriteLine("----------------------------------------------------------------------"); + Console.WriteLine("There are {0} numbers between 1 and 100 that are evenly divisible by 3", divideByThree()); + Console.WriteLine("----------------------------------------------------------------------"); - // Console.WriteLine("Enter a number you want the factorial of:"); - // Console.WriteLine(factorial()); - // Console.WriteLine("------------------------------------------------------------------------"); + Console.WriteLine("Enter a number you want the factorial of:"); + Console.WriteLine(factorial()); + Console.WriteLine("------------------------------------------------------------------------"); - // int secretNum = numGen(); - // int chances = 4; + int secretNum = numGen(); + int chances = 4; - // Console.WriteLine("--- The secret number is {0} ---", secretNum); - // Console.WriteLine("GUESS THE NUMBER:"); + Console.WriteLine("--- The secret number is {0} ---", secretNum); + Console.WriteLine("GUESS THE NUMBER:"); - // int guess = playerGuess(); - // while (chances > 0) - // { - // if (guess == secretNum) - // { - // Console.WriteLine("Congrats, You Win!"); - // break; - // } - - // else if (guess != secretNum) - // { - // chances--; - // Console.WriteLine("Wrong, you have {0} chance(s) left.", chances); - // playerGuess(); - // } - // if (chances == 0) - // { - // Console.WriteLine("You've run out of tries. Try again."); - // break; - // } + int guess = playerGuess(); + while (chances > 0) + { + if (guess == secretNum) + { + Console.WriteLine("Congrats, You Win!"); + break; + } - // } - // Console.WriteLine("----------------------------------------------------------------------------"); + else if (guess != secretNum) + { + chances--; + Console.WriteLine("Wrong, you have {0} chance(s) left.", chances); + playerGuess(); + } + if (chances == 0) + { + Console.WriteLine("You've run out of tries. Try again."); + break; + } + } + Console.WriteLine("----------------------------------------------------------------------------"); - // Console.WriteLine("Please enter a number. Enter 'OK' to add all previously entered numbers."); - // string userInput = AddInput(); - // int sum = 0; - // while (userInput != "ok") - // { - // sum = Convert.ToInt32(userInput) + sum; - - // userInput; + Console.WriteLine("Please enter a number. Enter 'OK' to add all previously entered numbers."); + string userInput = AddInput(); + int sum = 0; + while (userInput != "ok") + { + sum = Convert.ToInt32(userInput) + sum; + + AddInput(); + } + Console.WriteLine(sum); + Console.WriteLine("----------------------------------------------------------------------------------------"); + + + // Console.WriteLine("Enter in 5 numbers separated with a comma."); + + // string input = intialInput(); + + // List newList = new List(); + + // string[] container = input.Split(","); + + // newList.addAll(Arrays.asList(container)); + + // foreach(string word in newList) + // { + // Console.WriteLine(word); // } - // Console.WriteLine(sum); - // Console.WriteLine("----------------------------------------------------------------------------------------"); - - Console.WriteLine("Enter in 5 numbers separated with a comma."); - string input = - - - findMaxInArray(); + + + + + + + + + // findMaxInArray(); } @@ -115,25 +134,27 @@ public static int playerGuess() int num1 = Convert.ToInt32(Console.ReadLine()); return num1; } - //Add Numbers Project (Number 2 on List.): + + // Add Numbers Project (Number 2 on List.): public static string AddInput() { - string userInput = Console.ReadLine().ToLower(); + string userInput = Console.ReadLine(); + userInput.ToLower(); return userInput; } // Max Array Project (Number 5 on List.): - public static string intialInput() - { - string input = Console.ReadLine(); - return input; - } + // public static string intialInput() + // { + // string input = Console.ReadLine().ToLower(); + // return input; + // } - public static int findMaxInArray() - { + // public static List addToList() + // { - } + // } } From d58daa4b6e933c7feaf30ac6aeb581ccf0baed51 Mon Sep 17 00:00:00 2001 From: Forrest-Flowers Date: Wed, 28 Nov 2018 18:36:48 -0600 Subject: [PATCH 10/12] Delete Program.cs --- Checkpoint1/Program.cs | 166 ----------------------------------------- 1 file changed, 166 deletions(-) delete mode 100644 Checkpoint1/Program.cs diff --git a/Checkpoint1/Program.cs b/Checkpoint1/Program.cs deleted file mode 100644 index 5ad51a8c..00000000 --- a/Checkpoint1/Program.cs +++ /dev/null @@ -1,166 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Checkpoint1 -{ - class Program - { - static void Main(string[] args) - { - Console.WriteLine("There are {0} numbers between 1 and 100 that are evenly divisible by 3", divideByThree()); - Console.WriteLine("----------------------------------------------------------------------"); - - Console.WriteLine("Enter a number you want the factorial of:"); - Console.WriteLine(factorial()); - Console.WriteLine("------------------------------------------------------------------------"); - - int secretNum = numGen(); - int chances = 4; - - Console.WriteLine("--- The secret number is {0} ---", secretNum); - Console.WriteLine("GUESS THE NUMBER:"); - - int guess = playerGuess(); - while (chances > 0) - { - if (guess == secretNum) - { - Console.WriteLine("Congrats, You Win!"); - break; - } - - else if (guess != secretNum) - { - chances--; - Console.WriteLine("Wrong, you have {0} chance(s) left.", chances); - playerGuess(); - } - if (chances == 0) - { - Console.WriteLine("You've run out of tries. Try again."); - break; - } - - } - Console.WriteLine("----------------------------------------------------------------------------"); - - - Console.WriteLine("Please enter a number. Enter 'OK' to add all previously entered numbers."); - string userInput = AddInput(); - int sum = 0; - while (userInput != "ok") - { - sum = Convert.ToInt32(userInput) + sum; - - AddInput(); - } - Console.WriteLine(sum); - Console.WriteLine("----------------------------------------------------------------------------------------"); - - - // Console.WriteLine("Enter in 5 numbers separated with a comma."); - - // string input = intialInput(); - - // List newList = new List(); - - // string[] container = input.Split(","); - - // newList.addAll(Arrays.asList(container)); - - // foreach(string word in newList) - // { - // Console.WriteLine(word); - // } - - - - - - - - - - - - - - // findMaxInArray(); - - } - - //Divide By Three project (Number 1 on list): - public static int divideByThree() - { - int divisibleByThree = 0; - - for (int i = 0; i <= 100; i++) - { - if (i % 3 == 0) - { - divisibleByThree++; - } - } - return divisibleByThree; - } - //Factorials project (Number 3 on list): - public static string factorial() - { - int num = Convert.ToInt32(Console.ReadLine()); - int fact = num; - - //int i, num and fact. Start i at 1 less than input and go down to 1 then multiply those numbers together to find fact. - for (int i = num - 1; i >= 1; i--) - { - fact = fact * i; - } - - string equation = $"{num} != {fact}"; - - return equation; - } - - public static int numGen() - { - Random rnd = new Random(); - int num = rnd.Next(1, 11); - return num; - } - - - public static int playerGuess() - { - int num1 = Convert.ToInt32(Console.ReadLine()); - return num1; - } - - // Add Numbers Project (Number 2 on List.): - public static string AddInput() - { - string userInput = Console.ReadLine(); - userInput.ToLower(); - return userInput; - } - - // Max Array Project (Number 5 on List.): - - // public static string intialInput() - // { - // string input = Console.ReadLine().ToLower(); - // return input; - // } - - // public static List addToList() - // { - - // } - - - } - - - -} - - From 11fcd1e435600544df3b02e9b8894f890cbd20fb Mon Sep 17 00:00:00 2001 From: Forrest-Flowers Date: Wed, 28 Nov 2018 18:37:02 -0600 Subject: [PATCH 11/12] Delete Checkpoint1.csproj --- Checkpoint1/Checkpoint1.csproj | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 Checkpoint1/Checkpoint1.csproj diff --git a/Checkpoint1/Checkpoint1.csproj b/Checkpoint1/Checkpoint1.csproj deleted file mode 100644 index 23df6047..00000000 --- a/Checkpoint1/Checkpoint1.csproj +++ /dev/null @@ -1,8 +0,0 @@ - - - - Exe - netcoreapp2.1 - - - From 36a57d0c09bc487ed64f4301692c9f84edea9861 Mon Sep 17 00:00:00 2001 From: Forrest-Flowers Date: Mon, 3 Dec 2018 02:28:59 -0600 Subject: [PATCH 12/12] Fixed major fuckup in pushing the first time. --- Checkpoint1/Checkpoint1.cs | 92 +++++++++++++++++++++++++++++++++++++- 1 file changed, 90 insertions(+), 2 deletions(-) diff --git a/Checkpoint1/Checkpoint1.cs b/Checkpoint1/Checkpoint1.cs index b7ed8611..2d788b95 100644 --- a/Checkpoint1/Checkpoint1.cs +++ b/Checkpoint1/Checkpoint1.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; namespace Checkpoint1 { @@ -6,7 +7,94 @@ class Program { static void Main(string[] args) { - Console.WriteLine("Hello World!"); + Console.WriteLine("There are {0} numbers between 1 and 100 that are evenly divisible by 3", divideByThree()); + Console.WriteLine("----------------------------------------------------------------------"); + + Console.WriteLine("Enter a number you want the factorial of:"); + Console.WriteLine(factorial()); + Console.WriteLine("------------------------------------------------------------------------"); + + int secretNum = numGen(); + int chances = 4; + + + Console.WriteLine("GUESS THE NUMBER:"); + + + + + + while (chances > 0) + { + Console.WriteLine("THE SECRET NUMBER IS " +secretNum); + int guess = playerGuess(); + if (guess == secretNum) + { + Console.WriteLine("Congrats, You Win!"); + break; + } + else if (guess != secretNum) + { + chances--; + Console.WriteLine("Wrong, you have {0} chance(s) left.", chances); + } + + if (chances == 0) + { + Console.WriteLine("You've run out of tries. Try again."); + break; + } + } + + + Console.WriteLine("----------------------------------------------------------------------------"); } + //Divide By Three project (Number 1 on list): + public static int divideByThree() + { + int divisibleByThree = 0; + + for (int i = 0; i <= 100; i++) + { + if (i % 3 == 0) + { + divisibleByThree++; + } + } + return divisibleByThree; + } + + //Factorials project (Number 3 on list): + public static string factorial() + { + int num = Convert.ToInt32(Console.ReadLine()); + int fact = num; + + //int i, num and fact. Start i at 1 less than input and go down to 1 then multiply those numbers together to find fact. + for (int i = num - 1; i >= 1; i--) + { + fact = fact * i; + } + + string equation = $"{num} != {fact}"; + + return equation; + } + + //Guess the number project. + public static int numGen() + { + Random rnd = new Random(); + int num = rnd.Next(1, 11); + return num; + } + + + public static int playerGuess() + { + int num1 = Convert.ToInt32(Console.ReadLine()); + return num1; + } + } -} +} \ No newline at end of file