From 82b91fa29e23a67e51cd4920b40b3cba56c71187 Mon Sep 17 00:00:00 2001 From: Hanna Adenholm Date: Tue, 5 Aug 2025 14:40:29 +0200 Subject: [PATCH] finished ex --- src/main/java/com/booleanuk/core/Exercise.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/booleanuk/core/Exercise.java b/src/main/java/com/booleanuk/core/Exercise.java index 4d002b4..75a8da7 100644 --- a/src/main/java/com/booleanuk/core/Exercise.java +++ b/src/main/java/com/booleanuk/core/Exercise.java @@ -1,5 +1,7 @@ package com.booleanuk.core; +import java.util.Arrays; + public class Exercise { // The block of code below is a method definition. So far, you've been using methods created by other people // such as .length() and .charAt(n) @@ -23,7 +25,7 @@ public int[] one() { // Using an index, change the number 17 in the numbers array to 68 // WRITE YOUR CODE BETWEEN THIS LINE... - + numbers[2] = 68; // ... AND THIS LINE @@ -37,7 +39,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 @@ -48,13 +50,12 @@ 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 = {}; - return dummyArray; + return cars; } public int four() { @@ -64,7 +65,7 @@ public int four() { // sum of every number in the numbers array // WRITE YOUR CODE BETWEEN THIS LINE... - int result = 0; + int result = numbers[0] + numbers[1] + numbers[2] + numbers[3]; // ... AND THIS LINE @@ -75,12 +76,11 @@ 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 = {}; - return dummyArray; + return floats; } }