From eaf97b10740948262af3823463beee13706eb6be Mon Sep 17 00:00:00 2001 From: Petros Mylonas Date: Wed, 10 Jan 2024 15:58:29 +0200 Subject: [PATCH 1/2] Petros Mylonas --- src/main/java/com/booleanuk/core/Exercise.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/booleanuk/core/Exercise.java b/src/main/java/com/booleanuk/core/Exercise.java index f4aec33..df18c05 100644 --- a/src/main/java/com/booleanuk/core/Exercise.java +++ b/src/main/java/com/booleanuk/core/Exercise.java @@ -24,7 +24,7 @@ public int[] one() { // WRITE YOUR CODE BETWEEN THIS LINE... - + numbers[2]=68; // ... AND THIS LINE return numbers; @@ -37,7 +37,7 @@ public String two() { // teacher contained in the teachers array // WRITE YOUR CODE BETWEEN THIS LINE... - String teacher = ""; + String teacher = teachers[3]; // ... AND THIS LINE @@ -47,13 +47,13 @@ public String two() { public String[] three() { // 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 // Then change the code below to remove the dummyArray completely and return the cars array you created above instead. - String[] dummyArray = {}; + String[] dummyArray = cars; return dummyArray; } @@ -65,7 +65,9 @@ public int four() { // WRITE YOUR CODE BETWEEN THIS LINE... int result = 0; - + int i ; + for (i = 0; i < numbers.length; i++) + result += numbers[i]; // ... AND THIS LINE return result; @@ -74,13 +76,13 @@ public int four() { public float[] five() { // 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={9.62f,23.17f,3.14f}; // ... AND THIS LINE // Then change the code below to remove the dummyArray completely and return the floats array you created instead - float[] dummyArray = {}; + float[] dummyArray = floats; return dummyArray; } } From 328590ab4064def08ecdcbd31b9365daff3a878e Mon Sep 17 00:00:00 2001 From: Petros Mylonas Date: Thu, 11 Jan 2024 17:22:47 +0200 Subject: [PATCH 2/2] Petros Mylonas (fixed) --- src/main/java/com/booleanuk/core/Exercise.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/booleanuk/core/Exercise.java b/src/main/java/com/booleanuk/core/Exercise.java index df18c05..db0c084 100644 --- a/src/main/java/com/booleanuk/core/Exercise.java +++ b/src/main/java/com/booleanuk/core/Exercise.java @@ -53,8 +53,8 @@ public String[] three() { // ... AND THIS LINE // Then change the code below to remove the dummyArray completely and return the cars array you created above instead. - String[] dummyArray = cars; - return dummyArray; + + return cars; } public int four() {