From 76c0cdc32fedee2f8e1f047c85ecd5e81acbde9a Mon Sep 17 00:00:00 2001 From: Gulyapas Poonkawinsiri <67386394+joetlobb@users.noreply.github.com> Date: Mon, 7 Apr 2025 11:41:10 -0700 Subject: [PATCH 1/3] complete printItems function using for loop to iterate through items in a n array --- src/Practice.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Practice.java b/src/Practice.java index 89acfd9..ecac0d1 100644 --- a/src/Practice.java +++ b/src/Practice.java @@ -18,6 +18,9 @@ public class Practice { */ public static void printItems(String[] items) { // TODO: Implement this method here! + for (int i = 0; i < items.length; i++) { + System.out.println(items[i]); + } } /** From a1167bb2c78975febc2e55e817afb468fdc43ad2 Mon Sep 17 00:00:00 2001 From: Gulyapas Poonkawinsiri <67386394+joetlobb@users.noreply.github.com> Date: Mon, 7 Apr 2025 11:44:10 -0700 Subject: [PATCH 2/3] complete moreThanDouble function using if statement --- src/Practice.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Practice.java b/src/Practice.java index ecac0d1..8dbe0ba 100644 --- a/src/Practice.java +++ b/src/Practice.java @@ -48,6 +48,9 @@ public static void printItems(String[] items) { */ public static boolean moreThanDouble(int a, int b) { // TODO: Delete the dummy return statement and implement this method here! + if (a > (b * 2)) { + return true; + } return false; } From 85dc6f9661212c37cec85f3679c03449e5ed0730 Mon Sep 17 00:00:00 2001 From: Gulyapas Poonkawinsiri <67386394+joetlobb@users.noreply.github.com> Date: Mon, 7 Apr 2025 11:52:24 -0700 Subject: [PATCH 3/3] complete allStartWithA function with forEach loop and String method --- src/Practice.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Practice.java b/src/Practice.java index 8dbe0ba..921386f 100644 --- a/src/Practice.java +++ b/src/Practice.java @@ -77,7 +77,17 @@ public static boolean moreThanDouble(int a, int b) { */ public static boolean allStartWithA(String[] words) { // TODO: Delete the dummy return statement and implement this method here! - return false; + if (words.length == 0) return true; + + boolean result = false; + for (String word: words) { + if (word.toLowerCase().startsWith("a")) { + result = true; + } else { + return false; + } + } + return result; } public static void main(String[] args) {