diff --git a/src/Practice.java b/src/Practice.java index 89acfd9..5648a09 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,51 @@ 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; } - - - /** - * 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; - } + 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(); 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(); }