From 054d04006962d207597f0350be211754fc1a2d81 Mon Sep 17 00:00:00 2001 From: Johncarlo Perez Date: Tue, 8 Apr 2025 16:48:11 -0700 Subject: [PATCH 1/3] finish first method --- src/Practice.java | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/src/Practice.java b/src/Practice.java index 89acfd9..c86925f 100644 --- a/src/Practice.java +++ b/src/Practice.java @@ -18,6 +18,10 @@ 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]); + System.out.println("just a test"); + } } /** @@ -45,54 +49,39 @@ 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! + return false; } - - - /** - * Returns whether every word in the array starts with the letter A (either - * upper or lower case). - * - * Examples: - * input: - * {"alligators", "are", "AWESOME"} - * return: - * true - * - * input: - * {"apes", "can", "be", "amazing"} - * return: - * false - * - * Edge case: If array is empty, return true. - * + + /* * @param words a array of words * @return true if every word starts with A (case-insensitive), false otherwise. */ public static boolean allStartWithA(String[] words) { // TODO: Delete the dummy return statement and implement this method here! - return false; + + return true; } public static void main(String[] args) { System.out.println(); System.out.println("///// Print items /////"); System.out.println("Calling printItems(new String[]{\"welcome\", \"to\", \"sdev\", \"220\"})"); - printItems(new String[]{"welcome", "to", "sdev", "220"}); + printItems(new String[]{"stephn curry", "to", "Lebron", "James"}); System.out.println(); System.out.println("Calling printItems(new String[]{\"hello\", \"world\"})"); printItems(new String[]{"hello", "world"}); System.out.println(); System.out.println("///// More than Double /////"); - System.out.println("moreThanDouble(10, 3): " + moreThanDouble(10, 3)); + System.out.println("moreThanDouble(10, 3): " + moreThanDouble(90, 3)); System.out.println("moreThanDouble(6, 4): " + moreThanDouble(6, 4)); System.out.println("moreThanDouble(4, 2): " + moreThanDouble(4, 2)); System.out.println(); System.out.println("///// All Start With A /////"); - System.out.println("allStartWithA(new String[]{\"alligators\", \"are\", \"AWESOME\"}): " + allStartWithA(new String[]{"alligators", "are", "AWESOME"})); - System.out.println("allStartWithA(new String[]{\"apes\", \"can\", \"be\", \"amazing\"}): " + allStartWithA(new String[]{"apes", "can", "be", "amazing"})); + System.out.println("allStartWithA(new String[]{\"alligators\", \"are\", \"AWESOME\"}): " + allStartWithA(new String[]{"sdev220", "is", "NOT AWESOME"})); + System.out.println("allStartWithA(new String[]{\"apes\", \"can\", \"be\", \"amazing\"}): " + allStartWithA(new String[]{"stephen curry", "Lebron James", "be", "amazing"})); System.out.println("allStartWithA(new String[]{}): " + allStartWithA(new String[]{})); System.out.println(); } From 7c0ee5c39dc73cad91cb2e52cf4ef528cca6bf95 Mon Sep 17 00:00:00 2001 From: Johncarlo Perez Date: Tue, 8 Apr 2025 17:00:15 -0700 Subject: [PATCH 2/3] finish adding logic in the allStartWithA method --- src/Practice.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Practice.java b/src/Practice.java index c86925f..11734b6 100644 --- a/src/Practice.java +++ b/src/Practice.java @@ -59,9 +59,18 @@ 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 true; - } + if(words.length == 0){ + return true; + } + for(int i = 0; i < words.length; i++) { + char lowerCase = Character.toLowerCase(words[i].charAt(0)); + if(lowerCase != 'a') { + return false; + } + } + return true; + } + public static void main(String[] args) { System.out.println(); From 7a9d5b028e502c13327fd69831186ab58ebafb65 Mon Sep 17 00:00:00 2001 From: Johncarlo Perez Date: Tue, 8 Apr 2025 17:06:16 -0700 Subject: [PATCH 3/3] finished adding logic to moreThanDouble method --- src/Practice.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Practice.java b/src/Practice.java index 11734b6..5648a09 100644 --- a/src/Practice.java +++ b/src/Practice.java @@ -49,8 +49,11 @@ 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! - - return false; + int doubleValue = b * 2; + if (a > doubleValue) { + return true; + } + return false; } /*