Skip to content

Commit 148d6f3

Browse files
committed
All tests passed, Elisabeth Røysland
1 parent 337b13b commit 148d6f3

File tree

1 file changed

+16
-11
lines changed
  • csharp-fundamentals-arrays.Main

1 file changed

+16
-11
lines changed

csharp-fundamentals-arrays.Main/Core.cs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ public void example()
2626

2727
public int[] one()
2828
{
29-
throw new NotImplementedException();
29+
//throw new NotImplementedException();
3030
int[] numbers = { 42, 13, 17, 91 };
3131

3232
// 1. Values contained in an array are each stored at a unique numeric index, starting from 0 ascending in order.
3333
// E.g. The first value is at index 0, the second at index 1, the third at index 3.
3434
// Using an index, change the number 17 in the numbers array to 68
3535
// WRITE YOUR CODE BETWEEN THIS LINE...
3636

37-
37+
numbers[2] = 68;
3838

3939
// ... AND THIS LINE
4040

@@ -43,14 +43,14 @@ public int[] one()
4343

4444
public String two()
4545
{
46-
throw new NotImplementedException();
46+
//throw new NotImplementedException();
4747
String[] teachers = { "Nathan", "Ed", "Dave", "Carlo", "Lewis", "Jules", "John", "Chris", "Nigel" };
4848

4949
//TODO: 2. Using an array index, change the value of the teacher variable below to be the fourth
5050
// teacher contained in the teachers array
5151
// WRITE YOUR CODE BETWEEN THIS LINE...
5252

53-
String teacher = "";
53+
String teacher = teachers[3];
5454

5555
// ... AND THIS LINE
5656

@@ -59,26 +59,31 @@ public String two()
5959

6060
public String[] three()
6161
{
62-
throw new NotImplementedException();
62+
//throw new NotImplementedException();
6363
//TODO: 3. Create a string array named cars that contains three names of car manufacturers: Audi, BMW and Dodge
6464
// WRITE YOUR CODE BETWEEN THIS LINE...
6565

66-
66+
string[] cars = { "Audi", "BMW", "Dodge" };
6767

6868
// ... AND THIS LINE
6969

70-
//return cars;
70+
return cars;
7171
}
7272

7373
public int four()
7474
{
75-
throw new NotImplementedException();
75+
//throw new NotImplementedException();
7676
int[] numbers = { 42, 13, 17, 91 };
7777

7878
// TODO 4. Using array indices, set the value of the result variable below to the sum of every number in the numbers array
7979
// WRITE YOUR CODE BETWEEN THIS LINE...
8080

81-
int result = 0;
81+
int result = 0; //numbers.Sum();
82+
83+
for (int i = 0; i < numbers.Length; i++)
84+
{
85+
result += numbers[i];
86+
}
8287

8388
// ... AND THIS LINE
8489

@@ -87,11 +92,11 @@ public int four()
8792

8893
public float[] five()
8994
{
90-
throw new NotImplementedException();
95+
//throw new NotImplementedException();
9196
//TODO: 5. Create an array called floats that contains 3 floating point numbers: 9.62, 23.17 and 3.14
9297
// WRITE YOUR CODE BETWEEN THIS LINE...
9398

94-
float[] floats;
99+
float[] floats = { 9.62f, 23.17f, 3.14f};
95100

96101

97102
// ... AND THIS LINE

0 commit comments

Comments
 (0)