Skip to content

Commit 107caff

Browse files
committed
all tests passed
1 parent 337b13b commit 107caff

File tree

1 file changed

+19
-8
lines changed
  • csharp-fundamentals-arrays.Main

1 file changed

+19
-8
lines changed

csharp-fundamentals-arrays.Main/Core.cs

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

2727
public int[] one()
2828
{
29-
throw new NotImplementedException();
30-
int[] numbers = { 42, 13, 17, 91 };
29+
//throw new NotImplementedException();
30+
int[] numbers = { 42, 13, 68, 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.
@@ -43,14 +43,15 @@ 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

5353
String teacher = "";
54+
teacher = teachers[3];
5455

5556
// ... AND THIS LINE
5657

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

6061
public String[] three()
6162
{
62-
throw new NotImplementedException();
63+
//throw new NotImplementedException();
6364
//TODO: 3. Create a string array named cars that contains three names of car manufacturers: Audi, BMW and Dodge
6465
// WRITE YOUR CODE BETWEEN THIS LINE...
66+
string[] cars = { "Audi", "BMW", "Dodge" };
6567

6668

6769

6870
// ... AND THIS LINE
6971

70-
//return cars;
72+
return cars;
7173
}
7274

7375
public int four()
7476
{
75-
throw new NotImplementedException();
77+
//throw new NotImplementedException();
7678
int[] numbers = { 42, 13, 17, 91 };
7779

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

8183
int result = 0;
84+
for (int i = 0; i < numbers.Length; i++)
85+
{
86+
result += numbers[i];
87+
}
8288

8389
// ... AND THIS LINE
8490

@@ -87,11 +93,16 @@ public int four()
8793

8894
public float[] five()
8995
{
90-
throw new NotImplementedException();
96+
//throw new NotImplementedException();
9197
//TODO: 5. Create an array called floats that contains 3 floating point numbers: 9.62, 23.17 and 3.14
9298
// WRITE YOUR CODE BETWEEN THIS LINE...
9399

94-
float[] floats;
100+
float[] floats = new float[3];
101+
floats[0] = 9.62f;
102+
floats[1] = 23.17f;
103+
floats[2] = 3.14f;
104+
105+
95106

96107

97108
// ... AND THIS LINE

0 commit comments

Comments
 (0)