From e02112e241e483a4ca3d4517ff1d91e8895f0eee Mon Sep 17 00:00:00 2001 From: Dennis Rizah Nordvi Osmani Date: Tue, 13 Aug 2024 10:31:54 +0200 Subject: [PATCH 1/2] finished with one --- csharp-fundamentals-arrays.Main/Core.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/csharp-fundamentals-arrays.Main/Core.cs b/csharp-fundamentals-arrays.Main/Core.cs index 74d7769..d593670 100644 --- a/csharp-fundamentals-arrays.Main/Core.cs +++ b/csharp-fundamentals-arrays.Main/Core.cs @@ -26,7 +26,7 @@ public void example() public int[] one() { - throw new NotImplementedException(); + int[] numbers = { 42, 13, 17, 91 }; // 1. Values contained in an array are each stored at a unique numeric index, starting from 0 ascending in order. @@ -34,7 +34,8 @@ public int[] one() // Using an index, change the number 17 in the numbers array to 68 // WRITE YOUR CODE BETWEEN THIS LINE... - + // numbers.SetValue(68, 2); + numbers[2] = 68; // ... AND THIS LINE From 95d921b042261387d8c0dfad5c5ac8686754cdbd Mon Sep 17 00:00:00 2001 From: Dennis Rizah Nordvi Osmani Date: Tue, 13 Aug 2024 10:57:51 +0200 Subject: [PATCH 2/2] Dennis Osmani --- csharp-fundamentals-arrays.Main/Core.cs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/csharp-fundamentals-arrays.Main/Core.cs b/csharp-fundamentals-arrays.Main/Core.cs index d593670..fa87851 100644 --- a/csharp-fundamentals-arrays.Main/Core.cs +++ b/csharp-fundamentals-arrays.Main/Core.cs @@ -26,7 +26,7 @@ public void example() public int[] one() { - + // throw new NotImplementedException(); int[] numbers = { 42, 13, 17, 91 }; // 1. Values contained in an array are each stored at a unique numeric index, starting from 0 ascending in order. @@ -34,8 +34,8 @@ public int[] one() // Using an index, change the number 17 in the numbers array to 68 // WRITE YOUR CODE BETWEEN THIS LINE... - // numbers.SetValue(68, 2); - numbers[2] = 68; + numbers.SetValue(68, 2); + // numbers[2] = 68; // ... AND THIS LINE @@ -44,14 +44,14 @@ public int[] one() public String two() { - throw new NotImplementedException(); + // throw new NotImplementedException(); String[] teachers = { "Nathan", "Ed", "Dave", "Carlo", "Lewis", "Jules", "John", "Chris", "Nigel" }; //TODO: 2. Using an array index, change the value of the teacher variable below to be the fourth // teacher contained in the teachers array // WRITE YOUR CODE BETWEEN THIS LINE... - String teacher = ""; + String teacher = teachers[3]; // ... AND THIS LINE @@ -60,26 +60,24 @@ public String two() public String[] three() { - throw new NotImplementedException(); //TODO: 3. Create a string array named cars that contains three names of car manufacturers: Audi, BMW and Dodge // WRITE YOUR CODE BETWEEN THIS LINE... - + String[] cars = { "Audi", "BMW", "Dodge" }; // ... AND THIS LINE - //return cars; + return cars; } public int four() { - throw new NotImplementedException(); int[] numbers = { 42, 13, 17, 91 }; // TODO 4. Using array indices, set the value of the result variable below to the sum of every number in the numbers array // WRITE YOUR CODE BETWEEN THIS LINE... - int result = 0; + int result = numbers.Sum(); // ... AND THIS LINE @@ -88,11 +86,10 @@ public int four() public float[] five() { - throw new NotImplementedException(); //TODO: 5. Create an array called floats that contains 3 floating point numbers: 9.62, 23.17 and 3.14 // WRITE YOUR CODE BETWEEN THIS LINE... - float[] floats; + float[] floats = { 9.62f, 23.17f, 3.14f }; // ... AND THIS LINE