From 839a11ddcc8030131b6a982f07715adc116f0416 Mon Sep 17 00:00:00 2001 From: Isabell Date: Tue, 5 Aug 2025 13:43:26 +0200 Subject: [PATCH 1/2] Isabell Tran --- csharp-fundamentals-control-flow.Main/Core.cs | 63 ++++++++++++++----- 1 file changed, 49 insertions(+), 14 deletions(-) diff --git a/csharp-fundamentals-control-flow.Main/Core.cs b/csharp-fundamentals-control-flow.Main/Core.cs index 9fe1a9d..8db9da0 100644 --- a/csharp-fundamentals-control-flow.Main/Core.cs +++ b/csharp-fundamentals-control-flow.Main/Core.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO.Pipes; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -48,61 +49,73 @@ public string sayGoodMorning(bool isMorning) // Change the returned value in the method below to your answer. It is case-sensitive. public string one() { - return ""; + return "Good day!"; } //TODO: 2. What will the output be if I run sayGoodMorning(true)? // Change the returned value in the method below to your answer. It is case-sensitive. public string two() { - return ""; + return "Good morning!"; } //TODO: 3. What will the output be if I run sayGoodMorning("Hello" == "Hello")? // Change the returned value in the method below to your answer. It is case-sensitive. public string three() { - return ""; + return "Good morning!"; } //TODO: 4. What will the output be if I run sayGoodMorning("A word" != "Another word") public string four() { - return ""; + return "Good morning!"; } // 5. What will the output be if I run sayGoodMorning(25 != 25) public string five() { - return ""; + return "Good day!"; } //TODO: 6. Use a conditional statement to return "Correct!" if the input is more than 7 // or "Wrong!" if not public string six(int num) { - throw new NotImplementedException(); + if (num > 7) + return "Correct!"; + else + return "Wrong!"; } //TODO: 7. Use a conditional statement to return "Correct!" if the input is false // or "Wrong!" if not public string seven(bool boolean) { - throw new NotImplementedException(); + if (!boolean) + return "Correct!"; + else + return "Wrong!"; } //TODO: 8. Use a conditional statement to return "Correct!" if numOne is more than or equal to numTwo // or "Wrong!" if not public string eight(int numOne, int numTwo) { - throw new NotImplementedException(); + if (numOne >= numTwo) + return "Correct!"; + else + return "Wrong!"; } //TODO: 9. Use a conditional statement to return true if the array provided is not empty // or false if it is empty public bool nine(int[] nums) { - throw new NotImplementedException(); + if (nums.Length > 0) + return true; + else + return false; } //TODO: 10. Use a conditional statement to return true if the provided string contains the word @@ -110,7 +123,10 @@ public bool nine(int[] nums) // https://www.w3schools.com/java/java_ref_string.asp public bool ten(string sentence) { - throw new NotImplementedException(); + if (sentence.Contains("milk")) + return true; + else + return false; } //TODO: 11. Use conditional statements to return the number 3 if the provided string contains @@ -119,18 +135,28 @@ public bool ten(string sentence) // Otherwise, return the number 0. public int eleven(string sentence) { - throw new NotImplementedException(); + if (sentence.Contains("coffee") && sentence.Contains("milk")) + return 9; + if (sentence.Contains("milk")) + return 3; + if (sentence.Contains("coffee")) + return 6; + else + return 0; } //TODO: 12. Use conditional statements to return true if num is more than or equal to lower and is // less than or equal to upper, otherwise return false. public bool twelve(int num, int lower, int upper) { - throw new NotImplementedException(); + if ((num >= lower) && (num <= upper)) + return true; + else + return false; } /* - 12. Use conditional statements to return a string based on what the age parameter is. + 13. Use conditional statements to return a string based on what the age parameter is. The table below shows the string that should be returned for each range of values that age can be. For example: If age is 3, you should return "Toddler" 0 | Baby @@ -141,7 +167,16 @@ public bool twelve(int num, int lower, int upper) */ public string thirteen(int age) { - throw new NotImplementedException(); + if (age ==0) + return "Baby"; + else if (age > 0 && age < 5) + return "Toddler"; + else if (age > 4 && age < 13) + return "Child"; + else if (age > 12 && age < 20) + return "Teenager"; + else + return "Adult"; } } } From a9bcedb5e05c52f3a880d25b69bf69f66418f44f Mon Sep 17 00:00:00 2001 From: Isabell Date: Wed, 6 Aug 2025 14:34:58 +0200 Subject: [PATCH 2/2] All tests done --- csharp-fundamentals-control-flow.Main/Core.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/csharp-fundamentals-control-flow.Main/Core.cs b/csharp-fundamentals-control-flow.Main/Core.cs index 8db9da0..b0ddae6 100644 --- a/csharp-fundamentals-control-flow.Main/Core.cs +++ b/csharp-fundamentals-control-flow.Main/Core.cs @@ -178,5 +178,6 @@ public string thirteen(int age) else return "Adult"; } + } }